Skip to content

Commit

Permalink
Revert import assertions (#13911)
Browse files Browse the repository at this point in the history
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
  • Loading branch information
broofa and SimenB committed Feb 15, 2023
1 parent 5940bf4 commit 76ec2a4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 274 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

- `[jest-core]` allow to use workerIdleMemoryLimit with only 1 worker or runInBand option ([#13846](https://github.com/facebook/jest/pull/13846))
- `[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))
- `[jest-runtime]` Revert `import assertions` for JSON modules as it's been relegated to Stage 2 ([#13911](https://github.com/facebook/jest/pull/13911))

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`on node <16.12.0 does not enforce import assertions 1`] = `
exports[`does not enforce import assertions 1`] = `
"Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Expand Down
42 changes: 13 additions & 29 deletions e2e/__tests__/nativeEsm.test.ts
Expand Up @@ -94,24 +94,22 @@ test('runs WebAssembly (Wasm) test with native ESM', () => {
expect(exitCode).toBe(0);
});

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

const {rest} = extractSummary(stderr);
const {summary} = extractSummary(stderr);

expect(rest).toContain(
'package.json" needs an import assertion of type "json"',
);
expect(stdout).toBe('');
expect(exitCode).toBe(1);
});
expect(summary).toMatchSnapshot();
expect(stdout).toBe('');
expect(exitCode).toBe(0);
});

// version where `vm` API gets `import assertions`
onNodeVersions('>=16.12.0', () => {
test('supports import assertions', () => {
const {exitCode, stderr, stdout} = runJest(
DIR,
Expand All @@ -128,20 +126,6 @@ onNodeVersions('>=16.12.0', () => {
});

onNodeVersions('<16.12.0', () => {
test('does not enforce import assertions', () => {
const {exitCode, stderr, stdout} = runJest(
DIR,
['native-esm-missing-import-assertions.test'],
{nodeOptions: '--experimental-vm-modules --no-warnings'},
);

const {summary} = extractSummary(stderr);

expect(summary).toMatchSnapshot();
expect(stdout).toBe('');
expect(exitCode).toBe(0);
});

test('syntax error for import assertions', () => {
const {exitCode, stderr, stdout} = runJest(
DIR,
Expand Down
2 changes: 0 additions & 2 deletions packages/jest-runtime/package.json
Expand Up @@ -37,15 +37,13 @@
"jest-resolve": "workspace:^",
"jest-snapshot": "workspace:^",
"jest-util": "workspace:^",
"semver": "^7.3.5",
"slash": "^3.0.0",
"strip-bom": "^4.0.0"
},
"devDependencies": {
"@jest/test-utils": "workspace:^",
"@types/glob": "^7.1.1",
"@types/graceful-fs": "^4.1.3",
"@types/semver": "^7.1.0",
"jest-environment-node": "workspace:^"
},
"engines": {
Expand Down

This file was deleted.

0 comments on commit 76ec2a4

Please sign in to comment.