You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, create a test file that imports the JSON file without the import assertions like this:
// index.test.js// imports the JSON file without the import assertionsimporttestdatafrom"./testdata.json";import{expect,describe,test}from'@jest/globals';describe('',()=>{test('',async()=>{expect(1+1).toBe(2);})});
It's not currently enforced, see #12755. As mentioned there, not all node versions we support have support for that API. I guess we could just check if the current version supports it, tho
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
Version
29.3.1
Steps to reproduce
I'm using Jest's experimental ES Modules support.
First, create a test file that imports the JSON file without the import assertions like this:
Then run this:
> node --experimental-vm-modules node_modules/.bin/jest
As a result, an
ERR_IMPORT_ASSERTION_TYPE_MISSING
error should have occurred, but no error occurs.Expected behavior
Expect to get
ERR_IMPORT_ASSERTION_TYPE_MISSING
errors, just like when I run it in Node.js.Actual behavior
Exit without error.
Additional context
vm.SourceTextModule
can receive the value ofimportAssertions
when resolving import statements.https://nodejs.org/api/vm.html#new-vmsourcetextmodulecode-options
However, it seems that now the value of
importAssertions
is not respected.https://github.com/facebook/jest/blob/fb2de8a10f8e808b080af67aa771f67b5ea537ce/packages/jest-runtime/src/index.ts#L628-L631
Environment
Edit: Sorry if this was intentional behaviour.
The text was updated successfully, but these errors were encountered: