We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Object.freeze causes toEqual to trap because it is trying to mutate my data. This only happens when it actually finds a difference.
import { expect, test } from 'vitest' test('vitest trap', () => { const x = {a: { b: { c: 1 }}} const y = {a: { b: { c: 2 }}} Object.freeze(x.a); expect(x).toEqual(y); })
Throws the error: TypeError: Cannot assign to read only property 'b' of object '#'
System: OS: macOS 14.0 CPU: (10) arm64 Apple M1 Pro Memory: 2.24 GB / 16.00 GB Shell: 3.3.1 - /usr/local/bin/fish Binaries: Node: 20.8.0 - /usr/local/bin/node npm: 10.1.0 - /usr/local/bin/npm Browsers: Brave Browser: 87.1.18.78 Chrome: 117.0.5938.149 Safari: 17.0 npmPackages: @vitejs/plugin-react-swc: ^3.4.0 => 3.4.0 vite: ^4.4.9 => 4.4.9 vitest: ^0.34.6 => 0.34.6
npm
The text was updated successfully, but these errors were encountered:
Object.freeze
toEqual
Successfully merging a pull request may close this issue.
Describe the bug
Object.freeze causes toEqual to trap because it is trying to mutate my data. This only happens when it actually finds a difference.
Reproduction
import { expect, test } from 'vitest'
test('vitest trap', () => {
const x = {a: { b: { c: 1 }}}
const y = {a: { b: { c: 2 }}}
Object.freeze(x.a);
expect(x).toEqual(y);
})
Throws the error:
TypeError: Cannot assign to read only property 'b' of object '#'
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: