-
-
Notifications
You must be signed in to change notification settings - Fork 225
Open
Description
The toHaveBeenCalledExactlyOnceWith differentiates between a call where an argument with the value of undefined is passed and a call where nothing is passed. Technically this is a difference in JS but I would argue not a meaningfull one.
it('should not make a difference', () => {
const foo = {
bar: (needed: string, maybe?: string) => {},
}
const barSpy = vi.spyOn(foo, 'bar')
foo.bar('something')
// Works
expect(barSpy).toHaveBeenCalledExactlyOnceWith('something')
barSpy.mockReset()
const someArgument = undefined
foo.bar('something', someArgument)
// Works
expect(barSpy).toHaveBeenCalledExactlyOnceWith('something', undefined)
// Fails
expect(barSpy).toHaveBeenCalledExactlyOnceWith('something')
})I would expect the matcher to pass in all 3 scenarios.
Metadata
Metadata
Assignees
Labels
No labels