Changelog
[3.0.0] - 2020-11-01
spy.getAllCallArguments
was returning a wrong value.flow
supportnode
support for versions lower than 12new Spy()
-> Spy()
(Spy
is no longer a class)Changelog
[2.10.0] - 2019-11-06
spy.getAllCallArguments
: Provides a little more flexibility when observing call arguments.Changelog
[2.8.0] - 2019-11-03
Spy.mockModule
: Allows you to mock functions on module level. Can replace the usage of
jest.mock
in most situations. One example:
// some module with name "my-module.js"
export const useMe = (some: string) => 'foo' + some;
// testing somewhere else
const Mock$MyModule = Spy.mockModule('../my-stuff/my-module', 'useMe');
Mock$MyModule.useMe.returns(42);
expect(useMe('test')).toBe(42);
Mock$MyModule.useMe.hasCallHistory('test');
Changelog
[2.7.0] - 2019-11-03
More detailed error messages.
--> foo / different string
--> foo / different string ['bar' != 'test']
Improved UX for Spy.COMPARE
. You can make assertions that throw instead of returning a
boolean indicator. E.g.
spy.wasCalledWith(Spy.COMPARE(fn => {
expect(fn()).toEqual({ foo: 'bar' });
}));