New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Jasmine reports toEqual(0, Number.MIN_VALUE) to be true #1764
Conversation
d182a0d
to
97fe2e7
Compare
Could you elaborate on how you found this particular case? I tried running a port of the Jest test that you linked to against the revision of Jasmine just before your fix. It correctly failed, but only if I explicitly included I can definitely see the value in adding property tests to Jasmine's test suite, but I want to make sure I'm doing it right. Here's the test that I ran:
|
Detection of toEqual bug Indeed the probability to detect this particular case in a hundred runs is pretty low knowing the scope of inputs we have to cover (any objects ranging from For instance, in order to detect this bug in Jest (and some of the others jestjs/jest#7975 or jestjs/jest#7937), I artificially increased the number of runs locally to simulate multiple CI executions by adding Your implementation Looks good to me ;) You may want to add Property based philosophy In general when I introduce property based testing to others I often state the following: Today our tests are made of manually hardcoded scenarii that do not fully cover the range of all possible inputs of our functions - eg.: In order to cover more we need to introduce random. But random in a reproducible way (with a seed) and not deterministic because we want to try new scenarii at each CI runs (see google/oss-fuzz which shows the benefits of fuzz approach). Additionally contrary to a naive random generator, property based testing frameworks are able to reduce the bugs to smaller cases easier to troubleshoot for a human. Instead for reporting a crash on a one-million characters string it will report a smaller string with the minimal amount of data required to reproduce the bug. Please let me know if you need help to add property based to Jasmine I'm glad to see that you are considering the possibility to add property based into your test suites. |
@sgravrock Did you reproduce the issue? |
Yes, I did. By setting |
Description
The current implementation of toEqual returns an invalid answer for:
Similar to a bug found in Jest jestjs/jest#7941
Motivation and Context
This bug has been discovered when running property based testing test against Jest. Then I discovered the very same code was part of many other libs including Jasmine.
Please note that following this bug report on Jest, property based tests are now used within Jest to avoid future issues.
How Has This Been Tested?
Types of changes
Checklist: