jest: Doesn't work with `weak` on Node 12

Jest has --detectLeaks amazing feature that is powered by weak npm package.

The problem is that weak doesn’t work with Node 12 (I’ve opened an issue there: https://github.com/TooTallNate/node-weak/issues/99).

The best way would be for them to fix it. But, it looks not very maintained ATM.

At the same time I found that @danfuzz there suggesting to use other package as API-compatible replacement for weak that is using a sustainable NAPI: https://github.com/node-ffi-napi/weak-napi

Should we consider to try it and if it works to switch Jest to use that package instead?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 22 (14 by maintainers)

Most upvoted comments

Are there any news? I still don’t see any releases since August.

In which version of Jest is it available after all? Latest release was on Aug 15, so looks like this fix has not been released yet?

@dylanwulf mind opening up a new issue with that? Seems like we’re doing something the the globals in jsdom that we don’t clean up properly 🙂

I’m trying jest@25.0.0 available from npm, and it seems to work with node v12 but when I use the --detectLeaks option, every single test fails with a detected leak (even if the only thing in the test is a simple console.log)

It’s also possible to solve this by replacing weak with one of the forks in the upstream PR:

    "weak": "github:lxe/node-weak#node-12"

@SimenB I created a https://github.com/facebook/jest/pull/8686 to resolve this problem, can you review it?

I tried this here: https://github.com/SimenB/jest/tree/weak-napi

But the tests fail… Not sure if it’s a bug in the napi implementation or not

sure

Wanted to add node 12 to our test matrix, and it fails due to being unable to install weak. Wanna send a PR switching to the linked package? 😀 If it doesn’t support node 6, we’ll be dropping it as soon as we get the next release out (today, hopefully)

👋 FWIW I continue to have a good experience with weak-napi.

Very much open to switching!