Jest: expect('null').toContain(null) should fail

Created on 2 Mar 2019  路  3Comments  路  Source: facebook/jest

In https://github.com/facebook/jest/pull/8008#discussion_r261748762, we discovered that expect('asdf null asdf').toContain(null) passes and agreed that it shouldn't. This breaking change should be included in the next major. @SimenB

Most helpful comment

I vote 3 ("Papa bear").
This is the only really helpful message in case received turns out to be a string when the user actually thought it was an array and intended to use the array version of toContain.

Also, TIL where the term Goldilocks zone originates 馃槄

All 3 comments

Let鈥檚 also remember https://github.com/facebook/jest/pull/8008#issue-257184687

Breaking change to require .exec method in addition to .test method for RegExp

EDIT also for .toThrow and .toThrowError see https://github.com/facebook/jest/pull/8033#issue-257769410

Or to get to the root of the problem, see https://github.com/facebook/jest/pull/8033#discussion_r

Please critique 3 possible matcher error messages. Or suggest your own Goldilocks message :)

Baby bear is direct parallel with other error messages:

baby

baby-not

Mama bear makes the conditional requirement explicit:

mama

mama-not

Papa bear also displays received value because the message refers to it:

papa

papa-not

I vote 3 ("Papa bear").
This is the only really helpful message in case received turns out to be a string when the user actually thought it was an array and intended to use the array version of toContain.

Also, TIL where the term Goldilocks zone originates 馃槄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kentor picture kentor  路  3Comments

ianp picture ianp  路  3Comments

stephenlautier picture stephenlautier  路  3Comments

StephanBijzitter picture StephanBijzitter  路  3Comments

withinboredom picture withinboredom  路  3Comments