-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Expand file tree
/
Copy pathtestEnvironmentEsm.ts
More file actions
51 lines (41 loc) · 1.6 KB
/
Copy pathtestEnvironmentEsm.ts
File metadata and controls
51 lines (41 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {resolve} from 'path';
import {json as runJestJson} from '../runJest';
const DIR = resolve(__dirname, '../test-environment-esm');
it('support test environment written in ESM with `.ts` extension', () => {
const {exitCode, json} = runJestJson(DIR, ['testUsingTsEnv.test.js'], {
nodeOptions: '--experimental-vm-modules --no-warnings',
});
expect(exitCode).toBe(0);
expect(json.numTotalTests).toBe(1);
expect(json.numPassedTests).toBe(1);
});
it('support test environment written in ESM with `.mts` extension', () => {
const {exitCode, json} = runJestJson(DIR, ['testUsingMtsEnv.test.js'], {
nodeOptions: '--experimental-vm-modules --no-warnings',
});
expect(exitCode).toBe(0);
expect(json.numTotalTests).toBe(1);
expect(json.numPassedTests).toBe(1);
});
it('support test environment written in ESM with `.js` extension', () => {
const {exitCode, json} = runJestJson(DIR, ['testUsingJsEnv.test.js'], {
nodeOptions: '--experimental-vm-modules --no-warnings',
});
expect(exitCode).toBe(0);
expect(json.numTotalTests).toBe(1);
expect(json.numPassedTests).toBe(1);
});
it('support test environment written in ESM with `.mjs` extension', () => {
const {exitCode, json} = runJestJson(DIR, ['testUsingMjsEnv.test.js'], {
nodeOptions: '--experimental-vm-modules --no-warnings',
});
expect(exitCode).toBe(0);
expect(json.numTotalTests).toBe(1);
expect(json.numPassedTests).toBe(1);
});