this repository is a minimal reproduction of argument matching failing for imported functions when using testdouble in an ESM context
- clone this repository
- run
nvm useto switch your environment to the intended version of node (ornvm installif you don't already have a matching node version installed) - run
npm clean-installto install dependencies for the project - run
npm testto execute the unit tests demonstrating the problems
- the expectation
of
barbeing called withbazas the only argument fails even though it is called that way infoo.js, which is the SUT for that test. This passes as expected in a non-esm environment when usingtd.replacerather thantd.replaceEsm bazhas the same identity when imported into the test file and returned from the source file. this is the expected behaviorbazdoes not have the same identity when imported and returned the same way whentd.replaceEsmis used in the test, even when the replaced module is unrelated.