Now, checking if a spy was called or not called is great, but we can get even more detail out of our assertions. For example, what if I call the spy with the name Andrew and the age 25:
it('should call the spy correctly', () => {
var spy = expect.createSpy();
spy('Andrew', 25);
expect(spy).toHaveBeenCalled();
});
Now, we want to verify if the spy was not just called but was called with these arguments? Well, luckily, we have an assertion for that too. Instead of toHaveBeenCalled, we can call toHaveBeenCalledWith, and this lets us pass in some arguments and verify the spy was indeed called with those arguments.
As shown in the following code, we'll assert that my spy was called with Andrew and the number 25:
expect(spy).toHaveBeenCalledWith('Andrew', 25);
When we save the file and the test cases restart, we should see all the tests passing, and that's exactly what we get:

Now, if the spy was not called with the mentioned data, I'll remove 25:
it('should call the spy correctly', () => {
var spy = expect.createSpy();
spy('Andrew');
expect(spy).toHaveBeenCalledWith('Andrew', 25);
});
Now if we rerun the test suite, the test will fail. It will give you an error message letting you know that spy was never called with [ 'Andrew', 25 ]. This is causing the test to fail, which is fantastic.