Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert import assertions #13911

Merged
merged 7 commits into from Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.