-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
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 Properties are ignored in expect when there is a Symbol.iterator #5620
Comments
Note that also the iterator is ignored, the following keeps passing: import { describe, expect, it } from "vitest"
describe("Vitest Issue", () => {
it("compares", () => {
const a = {
value: 0,
[Symbol.iterator]: [0, 1, 2, Math.random()][Symbol.iterator]
}
const b = {
value: 1,
[Symbol.iterator]: [0, 1, 2, Math.random()][Symbol.iterator]
}
expect(a).toStrictEqual(b)
})
}) |
Looks like this was fixed in Jest after we migrated the equality check: jestjs/jest#8359 |
This one might be some > x = { [Symbol.iterator]: ["a", "b"][Symbol.iterator] }
{ [Symbol(Symbol.iterator)]: [Function: values] }
> x[Symbol.iterator]().next()
{ value: undefined, done: true }
> y = { [Symbol.iterator]: () => ["a", "b"][Symbol.iterator]() }
{ [Symbol(Symbol.iterator)]: [Function: [Symbol.iterator]] }
> y[Symbol.iterator]().next()
{ value: 'a', done: false } |
Closed by #5621 |
The fix should be in https://github.com/vitest-dev/vitest/releases/tag/v1.5.3 I checked and |
Thank you very much for checking, this issue actually highlighted that we were running in a limbo relying on the fact that only iterable would be compared, we are working on custom matchers to fill the gap Effect-TS/effect#2646 |
Describe the bug
When there is a
Symbol.iterator
inside an object vitest fails to check for other propertiesReproduction
The following test should fail:
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: