diff --git a/packages/expect/src/__tests__/__snapshots__/spyMatchers.test.ts.snap b/packages/expect/src/__tests__/__snapshots__/spyMatchers.test.ts.snap index 5a0a44b6a556..4bd06cf27559 100644 --- a/packages/expect/src/__tests__/__snapshots__/spyMatchers.test.ts.snap +++ b/packages/expect/src/__tests__/__snapshots__/spyMatchers.test.ts.snap @@ -242,6 +242,29 @@ Received Number of returns: 3 `; +exports[`lastReturnedWith returnedWith incomplete recursive calls are handled properly 1`] = ` +expect(jest.fn()).lastReturnedWith(expected) + +Expected: undefined +Received + 3: function call has not returned yet +-> 4: function call has not returned yet + +Number of returns: 0 +Number of calls: 4 +`; + +exports[`lastReturnedWith returnedWith works with more calls than the limit 1`] = ` +expect(jest.fn()).lastReturnedWith(expected) + +Expected: "bar" +Received + 5: "foo5" +-> 6: "foo6" + +Number of returns: 6 +`; + exports[`lastReturnedWith works only on spies or jest.fn 1`] = ` expect(received).lastReturnedWith(expected) @@ -2060,6 +2083,29 @@ Received Number of returns: 3 `; +exports[`toHaveLastReturnedWith returnedWith incomplete recursive calls are handled properly 1`] = ` +expect(jest.fn()).toHaveLastReturnedWith(expected) + +Expected: undefined +Received + 3: function call has not returned yet +-> 4: function call has not returned yet + +Number of returns: 0 +Number of calls: 4 +`; + +exports[`toHaveLastReturnedWith returnedWith works with more calls than the limit 1`] = ` +expect(jest.fn()).toHaveLastReturnedWith(expected) + +Expected: "bar" +Received + 5: "foo5" +-> 6: "foo6" + +Number of returns: 6 +`; + exports[`toHaveLastReturnedWith works only on spies or jest.fn 1`] = ` expect(received).toHaveLastReturnedWith(expected) diff --git a/packages/expect/src/__tests__/spyMatchers.test.ts b/packages/expect/src/__tests__/spyMatchers.test.ts index b9c248282cdb..db067499d444 100644 --- a/packages/expect/src/__tests__/spyMatchers.test.ts +++ b/packages/expect/src/__tests__/spyMatchers.test.ts @@ -1023,7 +1023,12 @@ describe.each([ ).toThrowErrorMatchingSnapshot(); }); - const basicReturnedWith = ['toHaveReturnedWith', 'toReturnWith']; + const basicReturnedWith = [ + 'toHaveLastReturnedWith', + 'lastReturnedWith', + 'toHaveReturnedWith', + 'toReturnWith', + ]; if (basicReturnedWith.indexOf(returnedWith) >= 0) { describe('returnedWith', () => { test('works with more calls than the limit', () => {