Skip to main content
Testing & QA Output Prediction Medium +20 XP

toHaveBeenCalledWith

What does this assertion check?

Testing & QARead-only
expect(sendEmail).toHaveBeenCalledWith('alice@test.com', 'Welcome');

What is the output?

Show answer and explanation

Answer: The mock was called with those exact arguments

toHaveBeenCalledWith verifies both that the mock was called AND that it received the specific arguments.

Hint: It checks both the call AND the arguments.

What this challenge tests

Output Prediction in Testing & QA: jest, mocking.

Related challenges