Skip to content

Commit 76ec2a4

Browse files
broofaSimenB
andauthored
Revert import assertions (#13911)
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
1 parent 5940bf4 commit 76ec2a4

File tree

7 files changed

+26
-274
lines changed

7 files changed

+26
-274
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- `[jest-core]` allow to use workerIdleMemoryLimit with only 1 worker or runInBand option ([#13846](https://github.com/facebook/jest/pull/13846))
66
- `[jest-message-util]` Add support for [error causes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) ([#13868](https://github.com/facebook/jest/pull/13868) & [#13912](https://github.com/facebook/jest/pull/13912))
7+
- `[jest-runtime]` Revert `import assertions` for JSON modules as it's been relegated to Stage 2 ([#13911](https://github.com/facebook/jest/pull/13911))
78

89
### Fixes
910

e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`on node <16.12.0 does not enforce import assertions 1`] = `
3+
exports[`does not enforce import assertions 1`] = `
44
"Test Suites: 1 passed, 1 total
55
Tests: 2 passed, 2 total
66
Snapshots: 0 total

e2e/__tests__/nativeEsm.test.ts

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,22 @@ test('runs WebAssembly (Wasm) test with native ESM', () => {
9494
expect(exitCode).toBe(0);
9595
});
9696

97-
// version where `vm` API gets `import assertions`
98-
onNodeVersions('>=16.12.0', () => {
99-
test('enforces import assertions', () => {
100-
const {exitCode, stderr, stdout} = runJest(
101-
DIR,
102-
['native-esm-missing-import-assertions.test'],
103-
{nodeOptions: '--experimental-vm-modules --no-warnings'},
104-
);
97+
test('does not enforce import assertions', () => {
98+
const {exitCode, stderr, stdout} = runJest(
99+
DIR,
100+
['native-esm-missing-import-assertions.test'],
101+
{nodeOptions: '--experimental-vm-modules --no-warnings'},
102+
);
105103

106-
const {rest} = extractSummary(stderr);
104+
const {summary} = extractSummary(stderr);
107105

108-
expect(rest).toContain(
109-
'package.json" needs an import assertion of type "json"',
110-
);
111-
expect(stdout).toBe('');
112-
expect(exitCode).toBe(1);
113-
});
106+
expect(summary).toMatchSnapshot();
107+
expect(stdout).toBe('');
108+
expect(exitCode).toBe(0);
109+
});
114110

111+
// version where `vm` API gets `import assertions`
112+
onNodeVersions('>=16.12.0', () => {
115113
test('supports import assertions', () => {
116114
const {exitCode, stderr, stdout} = runJest(
117115
DIR,
@@ -128,20 +126,6 @@ onNodeVersions('>=16.12.0', () => {
128126
});
129127

130128
onNodeVersions('<16.12.0', () => {
131-
test('does not enforce import assertions', () => {
132-
const {exitCode, stderr, stdout} = runJest(
133-
DIR,
134-
['native-esm-missing-import-assertions.test'],
135-
{nodeOptions: '--experimental-vm-modules --no-warnings'},
136-
);
137-
138-
const {summary} = extractSummary(stderr);
139-
140-
expect(summary).toMatchSnapshot();
141-
expect(stdout).toBe('');
142-
expect(exitCode).toBe(0);
143-
});
144-
145129
test('syntax error for import assertions', () => {
146130
const {exitCode, stderr, stdout} = runJest(
147131
DIR,

packages/jest-runtime/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@
3737
"jest-resolve": "workspace:^",
3838
"jest-snapshot": "workspace:^",
3939
"jest-util": "workspace:^",
40-
"semver": "^7.3.5",
4140
"slash": "^3.0.0",
4241
"strip-bom": "^4.0.0"
4342
},
4443
"devDependencies": {
4544
"@jest/test-utils": "workspace:^",
4645
"@types/glob": "^7.1.1",
4746
"@types/graceful-fs": "^4.1.3",
48-
"@types/semver": "^7.1.0",
4947
"jest-environment-node": "workspace:^"
5048
},
5149
"engines": {

packages/jest-runtime/src/__tests__/runtime_import_assertions.test.js

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)