Closed NickSun closed 2 years ago
You're installing the fakes in the module code. Mocha loads all modules before running the tests, therefore the second stub call happens before any tests are executed.
Solution: Install stubs in before
or beforeEach
hooks.
Describe the bug sandbox.restore() does not work on factory function
To Reproduce Project structure:
./.nvmrc
:./package.json
:./src/lib/index.js
:./src/lib/shared.js
:./src/service/one.js
:./src/service/two.js
:./test/one.spec.js
./test/two.spec.js
npm run test
returns error:TypeError: Attempted to wrap shared which is already wrapped
Expected behavior sandbox.restore() should restore original function behavior