toEqual doesn't do deep equal
just run:
expect({
target: {
value: 'a',
nodeType: 1
}
}).toEqual({
target: {
value: 'asd sad asd ad asdasdasd asdasdsa',
nodeType: 1
}
});
Test will pass
Test shoudn't pass
https://github.com/bondom/jest-bug
npx envinfo --preset jestPaste the results here:
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 8.10.0 - /usr/local/bin/node
npm: 6.0.1 - /usr/local/bin/npm
npmPackages:
jest: ^22.4.4 => 22.4.4
@bondom thanks for the report - the issue here is that the nodeType field makes Jest think that this is a dom node (see here).
This, for example, will fail:
expect({
target: {
value: "a",
type: 1
}
}).toEqual({
target: {
value: "asd sad asd ad asdasdasd asdasdsa",
type: 1
}
});
Was just about to write the same thing.
Can we make isDomNode more robust?
Jasmine's implementation is a _bit_ better: https://github.com/jasmine/jasmine/blob/e2d9eefccdca3916b341a4927de7919003525cbc/src/core/base.js#L103-L112
EDIT: Heh, fixed 2 weeks ago: https://github.com/jasmine/jasmine/commit/ced2b114e47d3e0e108781dab3627aabc8515813
How about documenting this speciality behaviour? There's nothing in the paragraph about toEqual. What could be worse than an unreliable test framework?
@yeahio this bug has been fixed, and I've just tried it out and confirmed that it still is fixed
Most helpful comment
@yeahio this bug has been fixed, and I've just tried it out and confirmed that it still is fixed