Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,29 @@ Received
Number of returns: <r>3</>
`;

exports[`lastReturnedWith returnedWith incomplete recursive calls are handled properly 1`] = `
<d>expect(</><r>jest.fn()</><d>).</>lastReturnedWith<d>(</><g>expected</><d>)</>

Expected: <g>undefined</>
Received
3: function call has not returned yet
-> 4: function call has not returned yet

Number of returns: <r>0</>
Number of calls: <r>4</>
`;

exports[`lastReturnedWith returnedWith works with more calls than the limit 1`] = `
<d>expect(</><r>jest.fn()</><d>).</>lastReturnedWith<d>(</><g>expected</><d>)</>

Expected: <g>"bar"</>
Received
5: <r>"foo5"</>
-> 6: <r>"foo6"</>

Number of returns: <r>6</>
`;

exports[`lastReturnedWith works only on spies or jest.fn 1`] = `
<d>expect(</><r>received</><d>).</>lastReturnedWith<d>(</><g>expected</><d>)</>

Expand Down Expand Up @@ -2060,6 +2083,29 @@ Received
Number of returns: <r>3</>
`;

exports[`toHaveLastReturnedWith returnedWith incomplete recursive calls are handled properly 1`] = `
<d>expect(</><r>jest.fn()</><d>).</>toHaveLastReturnedWith<d>(</><g>expected</><d>)</>

Expected: <g>undefined</>
Received
3: function call has not returned yet
-> 4: function call has not returned yet

Number of returns: <r>0</>
Number of calls: <r>4</>
`;

exports[`toHaveLastReturnedWith returnedWith works with more calls than the limit 1`] = `
<d>expect(</><r>jest.fn()</><d>).</>toHaveLastReturnedWith<d>(</><g>expected</><d>)</>

Expected: <g>"bar"</>
Received
5: <r>"foo5"</>
-> 6: <r>"foo6"</>

Number of returns: <r>6</>
`;

exports[`toHaveLastReturnedWith works only on spies or jest.fn 1`] = `
<d>expect(</><r>received</><d>).</>toHaveLastReturnedWith<d>(</><g>expected</><d>)</>

Expand Down
7 changes: 6 additions & 1 deletion packages/expect/src/__tests__/spyMatchers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down