-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toHaveBeenCalledBefore throw an error #147
Comments
Your using jest 23 right? this has been fixed in a PR that been merged in #132, However this has not yet been published, until then you will have to use either jest 22, or not use this matcher :P |
However the docs on here do say jest 22=< so its expected to be working in jest 23, I know the docs have been updated in #132 but is it worth keeping them compatible with 22 as well? |
Awesome thank you much for the feedback. Came up with a bad workaround ...
const moduleOrder: number[] = [];
const sut: ISauceCore = await Container.GetFromContainer(SauceCore).isReady;
const spyModuleStart: SpyInstance = jest.spyOn(Module.prototype, "start");
const spyModule2Start: SpyInstance = jest.spyOn(Module2.prototype, "start");
const spyModule3Start: SpyInstance = jest.spyOn(Module3.prototype, "start");
spyModuleStart.mockImplementation(async () =>
{
moduleOrder.push(1);
});
spyModule2Start.mockImplementation(async () =>
{
moduleOrder.push(2);
});
spyModule3Start.mockImplementation(async () =>
{
moduleOrder.push(3);
});
await sut.register(Module);
await sut.register(Module2);
await sut.register(Module3);
await sut.start();
expect(moduleOrder).toEqual(expect.arrayContaining([1, 2, 3]));
spyModuleStart.mockRestore();
spyModule2Start.mockRestore();
spyModule3Start.mockRestore();
... mocking my function and pushing to an array and checking the array against the expected :/ |
you could do const mock1 = jest.fn()
const mock2 = jest.fn()
expect(mock1.mock.invocationCallOrder).toBeLessThan(mock2.mock.invocationCallOrder) |
The jest api changed from timestamp to invocationCallOrder so you dont have to mock out a timeout function inside the jest.fn() to get the innvocation order. |
Thank you for the feedback |
Having the same problem... |
Hey thanks for raising this, sorry about the delay in getting this published! It is now out in v0.8.0 |
Bug
package
version: 0.7.2node
version: 10npm
(oryarn
) version: 1.7From the documentation example
you will get the following error
The text was updated successfully, but these errors were encountered: