Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Possible regression with native modules in ts-jest #765

Closed
charandas opened this issue Mar 26, 2019 · 4 comments
Closed

Possible regression with native modules in ts-jest #765

charandas opened this issue Mar 26, 2019 · 4 comments

Comments

@charandas
Copy link

@jdalton I wrote this tiny wrapper around the main grpc library. I get the following with ts-jest. If I skip the entrypoint lib/index.js here and instead import from lib/main.js, I can get tests to work provided I enable babel in the flow.

Do you know what might be happening? I am going to be using this wrapper in other projects, which use jest for their test setup, and I won't have the privilege of using main.js there, as the whole point of esm is to be able to use it from the entrypoint index.js.

❯ npm test

> [email protected] test /Users/charandas/serve/opensource/grpc-esm-repro
> npm run jest


> [email protected] jest /Users/charandas/serve/opensource/grpc-esm-repro
> jest

 FAIL  test/e2e.spec.ts
  ● Test suite failed to run

    Module did not self-register.

      at Runtime.requireModule (node_modules/jest-runtime/build/index.js:356:31)
      at Object.<anonymous> (node_modules/grpc/src/grpc_extension.js:32:13)

Test Suites: 1 failed, 1 total
@charandas charandas changed the title Possible regression with native modules in ts-jest, but not in pure jest environment Possible regression with native modules in ts-jest Mar 26, 2019
@jdalton jdalton added the bug label Mar 27, 2019
@jdalton
Copy link
Member

jdalton commented Mar 27, 2019

Hi @charandas!

I found the issue. This is related to the fact that Jest stores native modules on the primary module cache (not its own internal cache). We were deferring to Jest's cache within esm so missed the cache of the native module. I'll tweak things a bit to fix it.

Update:

I've fixed this locally 👌

@charandas
Copy link
Author

@jdalton is a release coming soon?

@charandas
Copy link
Author

Thank you!

@jdalton
Copy link
Member

jdalton commented Mar 29, 2019

esm v3.2.21 is released 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants