Skip to content

Replace `not.toBeEmpty` in two tests

Eduardo Sanz García requested to merge eduardosanz/fix-misleading-test into master

What does this MR do and why?

#toBeEmpty is imported from jQuery and the matcher tests :empty pseudo class (HTML element with not children). Hence, these expectations don't work:

  • expect([]).not.toBeEmpty() should fail, but it succeeds
  • expect({}).not.toBeEmpty() should fail, but it succeeds

We disallow #toBeEmpty in tests and substitute their usage for alternative approaches:

  • expect([].length).toBe(0)
  • expect([1].length).toBeGreaterThan(0)

Screenshots or screen recordings

N/A

How to set up and validate locally

N/A

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eduardo Sanz García

Merge request reports