diff --git a/src/expectation/it.ts b/src/expectation/it.ts index c2f3c09..0678864 100644 --- a/src/expectation/it.ts +++ b/src/expectation/it.ts @@ -283,6 +283,7 @@ const willCapture = ( return true; }, toJSON: () => name ?? 'captures', + getDiff: (actual) => ({ actual, expected: actual }), get value(): T | undefined { return capturedValue; }, diff --git a/src/expectation/matcher.spec.ts b/src/expectation/matcher.spec.ts index 9d312db..c39281f 100644 --- a/src/expectation/matcher.spec.ts +++ b/src/expectation/matcher.spec.ts @@ -626,5 +626,17 @@ describe('It', () => { expect(It.willCapture().toJSON()).toEqual('captures'); expect(It.willCapture('custom').toJSON()).toEqual('custom'); }); + + it('should print diff', () => { + expect(It.willCapture().getDiff('foo')).toEqual({ + actual: 'foo', + expected: 'foo', + }); + + expect(It.willCapture('captor').getDiff('foo')).toEqual({ + actual: 'foo', + expected: 'foo', + }); + }); }); });