-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enforce import assertions when importing JSON in ESM (#12755)
- Loading branch information
Showing
8 changed files
with
218 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
e2e/native-esm/__tests__/native-esm-import-assertions.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import json from '../package.json' assert {type: 'json'}; | ||
|
||
test('supports static import', () => { | ||
expect(json).toHaveProperty('jest.testEnvironment', 'node'); | ||
}); | ||
|
||
test('supports dynamic import', async () => { | ||
const {default: json} = await import('../package.json', { | ||
assert: {type: 'json'}, | ||
}); | ||
expect(json).toHaveProperty('jest.testEnvironment', 'node'); | ||
}); |
17 changes: 17 additions & 0 deletions
17
e2e/native-esm/__tests__/native-esm-missing-import-assertions.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import json from '../package.json'; | ||
|
||
test('supports static import', () => { | ||
expect(json).toHaveProperty('jest.testEnvironment', 'node'); | ||
}); | ||
|
||
test('supports dynamic import', async () => { | ||
const {default: json} = await import('../package.json'); | ||
expect(json).toHaveProperty('jest.testEnvironment', 'node'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.