-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
Version
29.5.0
Steps to reproduce
git clone git@github.com:peterrattew/jest-object-containing-example.git
npm install
npm run test
Expected behavior
In objectContaining.symbols.test.js
I would expect the first test to fail and the second test to pass, but it is currently the reverse.
When converting the Symols to strings or using toMatchObject
the correct tests pass.
➜ jest-object-containing-example (main) ✔ npm run test
> object-containing-example@0.0.0 test
> jest
FAIL ./toMatchObject.symols.test.js
● symbol: toMatchObject should fail
expect(received).toMatchObject(expected)
- Expected - 1
+ Received + 1
Object {
- Symbol(bar): "bar",
+ Symbol(foo): "foo",
}
4 |
5 | it('symbol: toMatchObject should fail', () => {
> 6 | expect(obj).toMatchObject({ [bar]: 'bar' });
| ^
7 | });
8 |
9 | it('symbol: toMatchObject should pass', () => {
at Object.toMatchObject (toMatchObject.symols.test.js:6:15)
FAIL ./objectContaining.symbols.test.js
● symbol: objectNotContaining should pass
expect(received).toEqual(expected) // deep equality
- Expected - 2
+ Received + 2
- ObjectNotContaining {
- Symbol(bar): "bar",
+ Object {
+ Symbol(foo): "foo",
}
8 |
9 | it('symbol: objectNotContaining should pass', () => {
> 10 | expect(obj).toEqual(expect.not.objectContaining({ [bar]: 'bar' }));
| ^
11 | });
12 |
at Object.toEqual (objectContaining.symbols.test.js:10:15)
FAIL ./objectContaining.strings.test.js
● string: objectContaining should fail
expect(received).toEqual(expected) // deep equality
- Expected - 2
+ Received + 2
- ObjectContaining {
- "bar": "bar",
+ Object {
+ "foo": "foo",
}
4 |
5 | it('string: objectContaining should fail', () => {
> 6 | expect(obj).toEqual(expect.objectContaining({ [bar]: 'bar' }));
| ^
7 | });
8 |
9 | it('string: objectNotContaining should pass', () => {
at Object.toEqual (objectContaining.strings.test.js:6:15)
Test Suites: 3 failed, 3 total
Tests: 3 failed, 3 passed, 6 total
Snapshots: 0 total
Time: 1.524 s, estimated 2 s
Ran all test suites.
Actual behavior
The first test in objectContaining.symbols.test.js
passes and the second fails.
Additional context
This is my first time raising a bug here so please let me know if I have done something wrong.
Environment
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 16.20.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.4.2 - /usr/local/bin/npm
pnpm: 8.6.3 - /usr/local/bin/pnpm
npmPackages:
jest: ^29.5.0 => 29.5.0
TomStrepsil, James-T-Ardian and andriyor