wasm-bindgen
wasm-bindgen copied to clipboard
Jest failures
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
- Used a jest setup file to polyfil with
web-encoding
- Used a jest setup file to polyfil with
-
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.
Sadly: https://github.com/facebook/jest/issues/11011