|
5 | 5 | * LICENSE file in the root directory of this source tree. |
6 | 6 | */ |
7 | 7 |
|
8 | | -import {resolve} from 'path'; |
| 8 | +import {relative, resolve} from 'path'; |
| 9 | +import type {AggregatedResult} from '@jest/test-result'; |
9 | 10 | import {run} from '../Utils'; |
10 | 11 |
|
11 | 12 | const dir = resolve(__dirname, '..', 'run-programmatically'); |
12 | 13 |
|
13 | | -test('run Jest programmatically cjs', () => { |
| 14 | +test('runCLI Jest programmatically cjs', () => { |
14 | 15 | const {stdout} = run('node cjs.js --version', dir); |
15 | 16 | expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[-\S]*-dev$/); |
16 | 17 | }); |
17 | 18 |
|
18 | | -test('run Jest programmatically esm', () => { |
| 19 | +test('runCLI Jest programmatically esm', () => { |
19 | 20 | const {stdout} = run('node index.js --version', dir); |
20 | 21 | expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[-\S]*-dev$/); |
21 | 22 | }); |
| 23 | + |
| 24 | +test('runCore Jest programmatically', () => { |
| 25 | + const {stdout} = run('node core.mjs', dir); |
| 26 | + const {startTime, ...results}: AggregatedResult = JSON.parse( |
| 27 | + stdout.split('==== results ====')[1], |
| 28 | + ); |
| 29 | + |
| 30 | + const prunedResults = { |
| 31 | + ...results, |
| 32 | + |
| 33 | + testResults: results.testResults.map( |
| 34 | + ({testFilePath, perfStats, ...testFileData}) => ({ |
| 35 | + ...testFileData, |
| 36 | + testFilePath: relative(dir, testFilePath), |
| 37 | + testResults: testFileData.testResults.map( |
| 38 | + ({duration, ...testResult}) => testResult, |
| 39 | + ), |
| 40 | + }), |
| 41 | + ), |
| 42 | + }; |
| 43 | + expect(prunedResults).toMatchSnapshot(); |
| 44 | +}); |
0 commit comments