ConstThere are some variations among the services depending on what needs tests might have, but overall there are three main usage patterns:
// The function often accepts parameters that control its behavior
const foo = mockServices.foo();
mock function.// You can optionally supply a subset of its methods to implement
const foo = mockServices.foo.mock({
someMethod: () => 'mocked result',
});
// After exercising your test, you can make assertions on the mock:
expect(foo.someMethod).toHaveBeenCalledTimes(2);
expect(foo.otherMethod).toHaveBeenCalledWith(testData);
await startTestBackend({
features: [
mockServices.foo.factory({
someMethod: () => 'mocked result',
})
],
});
Mock implementations of the core services, to be used in tests.