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
When adding a custom equality tester in vitest.setup, for example
function numberEquality(actual, expected) { return typeof expected === 'number' ? actual === expected : undefined; } expect.addEqualityTesters([ numberEquality ]);
it is not relayed to typed-array values in toStrictEqual matches.
A patch to fix the issue would be
diff --git a/node_modules/@vitest/expect/dist/index.js b/node_modules/@vitest/expect/dist/index.js index 868ffa8..c9c2d0e 100644 --- a/node_modules/@vitest/expect/dist/index.js +++ b/node_modules/@vitest/expect/dist/index.js @@ -433,7 +433,7 @@ function iterableEquality(a, b, customTesters = [], aStack = [], bStack = []) { if (!isImmutableList(a) && !isImmutableOrderedKeyed(a) && !isImmutableOrderedSet(a) && !isImmutableRecord(a)) { const aEntries = Object.entries(a); const bEntries = Object.entries(b); - if (!equals(aEntries, bEntries)) { + if (!equals(aEntries, bEntries, filteredCustomTesters)) { return false; } }
describe('the numberEquality equality tester', () => { // works it('attest equality of -0 and +0 within arrays', () => { expect([-0, 0, 0]).toStrictEqual([0, -0, 0]); }); // fails without patch it('attest equality of -0 and +0 within typed arrays', () => { expect(Float64Array.of(-0, 0, 0)).toStrictEqual(Float64Array.of(0, -0, 0)); }); });
System: OS: Linux 6.6 Gentoo Linux Binaries: Node: 20.12.1 - /usr/bin/node npm: 10.5.0 - /usr/bin/npm npmPackages: @vitest/coverage-istanbul: 2.0.2 => 2.0.2 @vitest/coverage-v8: 2.0.2 => 2.0.2 @vitest/expect: 2.0.2 => 2.0.2 vite: 5.3.3 => 5.3.3 vitest: 2.0.2 => 2.0.2
npm
The text was updated successfully, but these errors were encountered:
Thank you for the bug report. Would you be willing to open a PR with a fix and a test?
Sorry, something went wrong.
I'll try... #6140
fix(dev): fix relay of custom equality testers
8b949e9
close vitest-dev#6122
Successfully merging a pull request may close this issue.
Describe the bug
When adding a custom equality tester in vitest.setup, for example
it is not relayed to typed-array values in toStrictEqual matches.
A patch to fix the issue would be
Reproduction
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: