-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed as not planned
Closed as not planned
Copy link
Description
Version
29.2.2
Steps to reproduce
Execute the following test that fails:
class A {
#_a;
constructor(a) {
this.#_a = a;
}
get a() {
return this.#_a;
}
}
describe('toStrictEqual', () => {
it('should not consider class instances with getters that access private fields with different values as equal', () => {
expect(new A('v1')).not.toStrictEqual(new A('v2'));
});
});with the following jest config
export default {
testEnvironment: 'node',
transform: {},
};Also see stackblitz: https://stackblitz.com/edit/node-z2xset?file=index.spec.js
Expected behavior
I expect that the test above is successful.
Actual behavior
The test fails.
Additional context
This issue might be somehow related to the follwing issues, but I am not 100% sure as there are errors thrown in those issues.
- toEqual throws a TypeError when using getter to private field of class #10167
- Jest does not support private class fields #9022
Environment
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 7.17.0 - /usr/local/bin/npm
npmPackages:
jest: 29.2.2 => 29.2.2michkot