-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
Version
29.7.0
Steps to reproduce
- Clone https://github.com/fa93hws/jest-mobx-ts-jest-matchobject-issue
- npm install
- npm run test
- error occours
Expected behavior
They should match
Actual behavior
They didn't match
- Expected - 1
+ Received + 33
- Store {
+ Object {
"foo": false,
+ Symbol(mobx administration): Object {
+ "appliedAnnotations_": Object {
+ "foo": [Function decorator],
+ },
+ "changeListeners_": undefined,
+ "defaultAnnotation_": Object {
+ "annotationType_": "true",
+ "extend_": [Function extend_$5],
+ "make_": [Function make_$5],
+ "options_": undefined,
+ },
+ "interceptors_": undefined,
+ "isPlainObject_": false,
+ "keysAtom_": Object {
+ "diffValue_": 0,
+ "isBeingObserved_": false,
+ "isPendingUnobservation_": false,
+ "lastAccessedBy_": 0,
+ "lowestObserverState_": 2,
+ "name_": "Store@1.keys",
+ "observers_": Set {},
+ "onBOL": undefined,
+ "onBUOL": undefined,
+ },
+ "name_": "Store@1",
+ "pendingKeys_": undefined,
+ "proxy_": undefined,
+ "target_": [Circular],
+ "values_": Map {
+ "foo" => false,
+ },
+ },
Additional context
The issues has occurred before mobxjs/mobx#1613 and is fixed in https://github.com/jestjs/jest/pull/7448/files.
It works fine on jest@28.1.3 but breaks after I upgrade it to jest@29.7.0
For curiosity, I add some console.log to my test and I see these symbols are not enumerable.
describe('store', () > {
it('should match', () => {
const store = new Store();
store.foo = false;
const anotherStore = new Store();
Object.getOwnPropertySymbols(store).forEach(s => {
const isEnumerable = Object.getOwnPropertyDescriptor(store, s).enumerable;
console.log(s, 'store', isEnumerable);
});
Object.getOwnPropertySymbols(anotherStore).forEach(s => {
const isEnumerable = Object.getOwnPropertyDescriptor(anotherStore, s).enumerable;
console.log(s, 'anotherStore', isEnumerable);
});
expect(store).toMatchObject(anotherStore);
})
})
However, when adding console.log to code in pretty-format
in getKeysOfEnumerableProperties function, these symbols become enumerable.
Environment
System:
OS: macOS 13.6.1
CPU: (10) arm64 Apple M1 Max
Binaries:
Node: 20.8.1 - /opt/homebrew/bin/node
Yarn: 1.22.18 - /opt/homebrew/bin/yarn
npm: 10.1.0 - /opt/homebrew/bin/npm
npmPackages:
jest: ^29.7.0 => 29.7.0