|
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +import {resolve} from 'path'; |
| 9 | +import wrap from 'jest-snapshot-serializer-raw'; |
| 10 | +import {onNodeVersions} from '@jest/test-utils'; |
| 11 | +import runJest, {getConfig} from '../runJest'; |
| 12 | +import {extractSummary} from '../Utils'; |
| 13 | + |
| 14 | +const DIR = resolve(__dirname, '../native-esm'); |
| 15 | + |
| 16 | +test('test config is without transform', () => { |
| 17 | + const {configs} = getConfig(DIR); |
| 18 | + |
| 19 | + expect(configs).toHaveLength(1); |
| 20 | + expect(configs[0].transform).toEqual([]); |
| 21 | +}); |
| 22 | + |
| 23 | +// The versions vm.Module was introduced |
| 24 | +onNodeVersions('^12.16.0 || >=13.0.0', () => { |
| 25 | + test('runs test with native ESM', () => { |
| 26 | + const {exitCode, stderr, stdout} = runJest(DIR, [], { |
| 27 | + nodeOptions: '--experimental-vm-modules', |
| 28 | + }); |
| 29 | + |
| 30 | + const {summary} = extractSummary(stderr); |
| 31 | + |
| 32 | + expect(wrap(summary)).toMatchSnapshot(); |
| 33 | + expect(stdout).toBe(''); |
| 34 | + expect(exitCode).toBe(0); |
| 35 | + }); |
| 36 | +}); |
0 commit comments