|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | import {resolve} from 'path'; |
9 | | -import runJest from '../runJest'; |
| 9 | +import {json as runJestJson} from '../runJest'; |
10 | 10 |
|
11 | | -it('support test environment written in ESM', () => { |
12 | | - const DIR = resolve(__dirname, '../test-environment-esm'); |
13 | | - const {exitCode} = runJest(DIR); |
| 11 | +const DIR = resolve(__dirname, '../test-environment-esm'); |
| 12 | + |
| 13 | +it('support test environment written in ESM with `.ts` extension', () => { |
| 14 | + const {exitCode, json} = runJestJson(DIR, ['testUsingTsEnv.test.js'], { |
| 15 | + nodeOptions: '--experimental-vm-modules --no-warnings', |
| 16 | + }); |
| 17 | + |
| 18 | + expect(exitCode).toBe(0); |
| 19 | + expect(json.numTotalTests).toBe(1); |
| 20 | + expect(json.numPassedTests).toBe(1); |
| 21 | +}); |
| 22 | + |
| 23 | +it('support test environment written in ESM with `.mts` extension', () => { |
| 24 | + const {exitCode, json} = runJestJson(DIR, ['testUsingMtsEnv.test.js'], { |
| 25 | + nodeOptions: '--experimental-vm-modules --no-warnings', |
| 26 | + }); |
| 27 | + |
| 28 | + expect(exitCode).toBe(0); |
| 29 | + expect(json.numTotalTests).toBe(1); |
| 30 | + expect(json.numPassedTests).toBe(1); |
| 31 | +}); |
| 32 | + |
| 33 | +it('support test environment written in ESM with `.js` extension', () => { |
| 34 | + const {exitCode, json} = runJestJson(DIR, ['testUsingJsEnv.test.js'], { |
| 35 | + nodeOptions: '--experimental-vm-modules --no-warnings', |
| 36 | + }); |
| 37 | + |
| 38 | + expect(exitCode).toBe(0); |
| 39 | + expect(json.numTotalTests).toBe(1); |
| 40 | + expect(json.numPassedTests).toBe(1); |
| 41 | +}); |
| 42 | + |
| 43 | +it('support test environment written in ESM with `.mjs` extension', () => { |
| 44 | + const {exitCode, json} = runJestJson(DIR, ['testUsingMjsEnv.test.js'], { |
| 45 | + nodeOptions: '--experimental-vm-modules --no-warnings', |
| 46 | + }); |
14 | 47 |
|
15 | 48 | expect(exitCode).toBe(0); |
| 49 | + expect(json.numTotalTests).toBe(1); |
| 50 | + expect(json.numPassedTests).toBe(1); |
16 | 51 | }); |
0 commit comments