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

[Bug]: toHaveBeenCalledWith matcher matches with any URL object #15032

Open
yatki opened this issue Apr 19, 2024 · 0 comments
Open

[Bug]: toHaveBeenCalledWith matcher matches with any URL object #15032

yatki opened this issue Apr 19, 2024 · 0 comments

Comments

@yatki
Copy link

yatki commented Apr 19, 2024

Version

29.7.0

Steps to reproduce

Please run the test below

it('toHaveBeenCalledWith not working with URL object', () => {
    const spy = jest.fn()

    spy(new URL('http://demo'))

    expect(spy).toHaveBeenCalledWith(new URL('http://demo'))
    expect(spy).toHaveBeenCalledWith(new URL('http://demo2'))
    expect(spy).toHaveBeenCalledWith(new URL('http://demo3'))
  })

Expected behavior

I either expect the last 2 assertions to fail or since the object references are different, I expect all assertions to fail.

Actual behavior

But all assertions pass.

Additional context

No response

Environment

MacOS 14.4.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant