Closed
Description
openedon Dec 25, 2022
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:
// index.test.js
// imports the JSON file without the import assertions
import testdata from "./testdata.json";
import { expect, describe, test } from '@jest/globals';
describe('', () => {
test('', async () => {
expect(1 + 1).toBe(2);
})
});
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 of importAssertions
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.
Environment
System:
OS: macOS 12.3
CPU: (8) arm64 Apple M1 Pro
Binaries:
Node: 16.17.1 - ~/.anyenv/envs/nodenv/versions/16.17.1/bin/node
npm: 9.2.0 - ~/.anyenv/envs/nodenv/versions/16.17.1/bin/npm
npmPackages:
jest: ^29.3.1 => 29.3.1
Edit: Sorry if this was intentional behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment