You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using replaceEsm breaks usage of Mongo in the files under test
Issue
See repo for details. I have a module, A with a dependency on another module, B. Module A queries Mongo DB. When testing module A, I call replaceEsm('path/to/B') and this causes all queries to Mongo in module A to return nothing. However, I also have another module C which also queries Mongo. If I make calls to module C from the tests of module A, the mongo queries work as expected.
It seems there might be an issue with replaceEsm + imports in beforeEach + mongo db.
Environment
node -v output: v17.6.0
npm -v (or yarn --version) output: 8.5.1
npm ls testdouble (or yarn list testdouble) version:
example@ /Users/paymahn/code/tripvector/example
└── testdouble@3.16.5
Unfortunately, when running the sample repo it has a problem connecting to mongo, which makes sense given that I don't have mongo isntalled. If you can give me instructions on how to run this test with a mongo on docker, I'd love to help.
Note that looking at the code, you're td.replaceEsm-ing the validations.jsafter you've imported the module, so even if mongo works, your mocking of that module won't really happen.
Description
Using
replaceEsm
breaks usage of Mongo in the files under testIssue
See repo for details. I have a module,
A
with a dependency on another module,B
. ModuleA
queries Mongo DB. When testing moduleA
, I callreplaceEsm('path/to/B')
and this causes all queries to Mongo in moduleA
to return nothing. However, I also have another moduleC
which also queries Mongo. If I make calls to module C from the tests of module A, the mongo queries work as expected.It seems there might be an issue with
replaceEsm
+ imports inbeforeEach
+ mongo db.Environment
node -v
output: v17.6.0npm -v
(oryarn --version
) output: 8.5.1npm ls testdouble
(oryarn list testdouble
) version:example@ /Users/paymahn/code/tripvector/example
└── testdouble@3.16.5
Example Repo
Here's a minimal repo: https://github.com/paymog/testdouble-example
The text was updated successfully, but these errors were encountered: