Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't handle transpiled modules + tests #16

Open
Quantumplation opened this issue Nov 7, 2017 · 0 comments
Open

Doesn't handle transpiled modules + tests #16

Quantumplation opened this issue Nov 7, 2017 · 0 comments

Comments

@Quantumplation
Copy link

Quantumplation commented Nov 7, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant