Closed VonRehberg closed 3 months ago
Thanks for maintaining these tools and for merging!
I was considering to mark my commit as a breaking change instead of a patch. In my opinion it fixes an issue, but it could cause a lot of tests to fail in packages using renovate. Please consider this when publishing to npm
Hi guys, this causes a major regression. For example, we can't use jest-when lib anymore as the returned mock is now a proxy and not jest.fn()
and as such we can't set any properties to it.
Please undo this and find a better solution for the issue that initiated this PR.
The following test passes in 0.5.0, but fails in 0.5.1. Still trying to figure out why it fails.
import { createMock } from '@golevelup/ts-jest';
describe(`test`, () => {
it('mock called with another mock', async () => {
interface Test {
foo(): number | undefined;
}
const mock = createMock<Test>();
mock.foo.mockImplementation(() => {
return 6;
});
expect(mock.foo()).toEqual(6);
mock.foo.mockImplementation(() => {
return 7;
});
expect(mock.foo()).toEqual(7);
mock.foo.mockImplementation(() => {
return 0;
});
expect(mock.foo()).toEqual(0); // Fails
mock.foo.mockImplementation(() => {
return undefined;
});
expect(mock.foo()).toEqual(undefined); //Fails
});
});
Error: Unexpected return from a matcher function.
Matcher functions should return an object in the following format:
{message?: string | function, pass: boolean}
'{"actual": [Function mockConstructor], "expected": 0, "message": [Function anonymous], "name": "toEqual", "pass": [Function mockConstructor]}' was returned
The new apply
trap is causing the issue, working on a fix
This PR fixes issue #703