Extend for Jest expect library.
Native node test runner does have diffrent mock structure from jest.mock therefore the extension of current methods is necessary.yst
Since native node test runner doesn't have any global setup, use this extension by import in every test:
import 'expect-matcher-node-mock';
The extend
of expect
matchers is included in this import and expect
is also exported out of this module = its possible to import expect
and extend matchers at once:
import { expect } from 'expect-matcher-node-mock';
...
https://jestjs.io/docs/expect#tohavebeencalled
https://jestjs.io/docs/expect#tohavebeencalledtimesnumber
https://jestjs.io/docs/expect#tohavebeencalledwitharg1-arg2-
https://jestjs.io/docs/expect#tohavebeenlastcalledwitharg1-arg2-
https://jestjs.io/docs/expect#tohavebeennthcalledwithnthcall-arg1-arg2-
alias toReturn
https://jestjs.io/docs/expect#tohavereturned
https://jestjs.io/docs/expect#tohavereturnedtimesnumber
https://jestjs.io/docs/expect#tohavereturnedwithvalue
https://jestjs.io/docs/expect#tohavelastreturnedwithvalue
https://jestjs.io/docs/expect#tohaventhreturnedwithnthcall-value