-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Hello!
Similar to #5, this module isn't handling transpiled modules cleanly, specifically when consuming them from unit tests.
Our directory structure is (more or less) as follows:
.
├── package.json
├── spec
│ └── unit
│ └── base-client.spec.ts
├── src
│ ├── index.ts
│ └── clients
│ └── base-client.ts
└── tsconfig.json
which is typescript code that gets transpiled to the dist directory.
and our package.json contains:
{
"name": "my-module",
"version": "0.0.0",
"main": "dist/index.js",
...
}
Notably, our entrypoint is dist/index.js, which is the transpiled form of src/index.ts.
I believe (but have not yet tested) that this would work correctly when our module is actually required externally. However, there is no way for us to unit test that this behavior is working correctly, as either
- the module.register doesn't get run, and thus the subsequent
.get()returns undefined - the module.register does get run (by importing our module rather than the file under test), but breaks, because it is making assumptions about there being an index.js in the root directory
For now, I'm just adding a null check to where we search for optional dependencies, and avoiding unit testing this behavior. Having looked at the code, I'm not even sure how you WOULD resolve this. I thought I'd throw it out there in case you had any better ideas.