jest: `toStrictEqual` fails to distinguish 0 from 5e-324

๐Ÿ› Bug Report

While trying to automate the detection of bugs and regressions in Jest (see my previous PR #7938), I found a very strange failing case in toStrictEqual:

expect(0).not.toStrictEqual(5e-324) // throws

//    expect(received).not.toStrictEqual(expected)
//
//    Expected: 5e-324
//    Received: 0

To Reproduce

Steps to reproduce the behavior: expect(0).not.toStrictEqual(5e-324)

Expected behavior

I would have expect Jest to succeed to distinguish 0 from 5e-324.

Run npx envinfo --preset jest

Paste the results here:

$ npx envinfo --preset jest
npx : 1 installรฉ(s) en 4.679s

  System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  Binaries:
    Node: 10.12.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.10.1 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.7.0 - C:\Program Files\nodejs\npm.CMD

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

Thank you. I have enjoyed the interaction. I wrote a comment in PR about CI and 2 suggested tests.

Iโ€™m fine with people needing to polyfill Object.is, fwiw

Thanks a lot for your help on this issue