wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

Jest failures

Open wilfredjonathanjames opened this issue 1 year ago • 1 comments

Describe the Bug

We're currently jest-testing a wasm-pack built library running inside of a Next.js application.

Build target is web. Jest version is 27.5.1.

The errors and solutions so far:

  • Cannot use 'import.meta' outside a module
  • ReferenceError: TextEncoder is not defined
  • TypeError: Cannot read properties of undefined (reading '__wbindgen_malloc')
    • No solution yet, but I'll keep you updated.

This seems to be caused by the deficiencies of jsdom.

Is it possible to solve all of these issues in some simple way? Should I be trying to build nodejs in jest and web everywhere else?

That does seem to work, but I haven't tried to find a way to achieve that automatically. I'll give that a go now.

Steps to Reproduce

Should be as simple as trying to use a web built lib in jest. Let me know if you have trouble.

Expected Behavior

Should just work in Jest.

Actual Behavior

Definitely doesn't just work in Jest.

wilfredjonathanjames avatar Sep 05 '22 03:09 wilfredjonathanjames

Sadly: https://github.com/facebook/jest/issues/11011

gthb avatar Sep 05 '22 07:09 gthb