Mock implementations of the core services, to be used in tests.
Remarks
There are some variations among the services depending on what needs tests
might have, but overall there are three main usage patterns:
Creating an actual fake service instance, often with a simplified version
of functionality, by calling the mock service itself as a function.
// The function often accepts parameters that control its behavior constfoo = mockServices.foo();
Creating a mock service, where all methods are replaced with jest mocks, by
calling the service's mock function.
// You can optionally supply a subset of its methods to implement constfoo = 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);
Creating a service factory that behaves similarly to the mock as per above.
Mock implementations of the core services, to be used in tests.
Remarks
There are some variations among the services depending on what needs tests might have, but overall there are three main usage patterns:
mockfunction.