Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 1.57 KB

README.md

File metadata and controls

25 lines (20 loc) · 1.57 KB

testdouble-esm-repro

this repository is a minimal reproduction of argument matching failing for imported functions when using testdouble in an ESM context

Steps to execute

  1. clone this repository
  2. run nvm use to switch your environment to the intended version of node (or nvm install if you don't already have a matching node version installed)
  3. run npm clean-install to install dependencies for the project
  4. run npm test to execute the unit tests demonstrating the problems

Highlights

  • the expectation of bar being called with baz as the only argument fails even though it is called that way in foo.js, which is the SUT for that test. This passes as expected in a non-esm environment when using td.replace rather than td.replaceEsm
  • baz has the same identity when imported into the test file and returned from the source file. this is the expected behavior
  • baz does not have the same identity when imported and returned the same way when td.replaceEsm is used in the test, even when the replaced module is unrelated.