Skip to content
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

fix(expect): expect.toEqual need to return original obj #4242

Closed
wants to merge 5 commits into from

Conversation

eryue0220
Copy link
Contributor

If support addEqualityTester, this case will fail, because it return a new object.

import { expect } from "https://deno.land/std/expect/mod.ts";

class Volume { /* specify logic*/ }

function createVolume() {
  return new Volume();
}

function areVolumeEqual(a: unknown, b unknown) {
   return a instacneof Volume && b instanceof Volume
}

Deno.test('custom equality tester', () => {
    expect.addEqualityTester([areVolumeEqual]);
    const volume1 = createVolume();
    const volume2 = createVolume();
    expect(volume1).toEqual(volume2);
});

And current expect(source1).toEqual(source2) will return false.

@eryue0220 eryue0220 requested a review from kt3k as a code owner January 26, 2024 07:24
@CLAassistant
Copy link

CLAassistant commented Jan 26, 2024

CLA assistant check
All committers have signed the CLA.

@kt3k
Copy link
Member

kt3k commented Jan 26, 2024

This modifies the input object. That doesn't look a good idea.

@eryue0220 eryue0220 marked this pull request as draft January 26, 2024 13:47
@eryue0220
Copy link
Contributor Author

This modifies the input object. That doesn't look a good idea.

Yeah, I'll consider other solutions.

@eryue0220 eryue0220 marked this pull request as ready for review January 27, 2024 04:49
@eryue0220
Copy link
Contributor Author

If the #4246 is merged, this pr will be solved as well. And it's no need any more.

@eryue0220 eryue0220 closed this Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants