mirror of
https://github.com/hanzoai/jest.git
synced 2026-09-24 16:59:57 +00:00
fix(jest-config): add mts and cts to default moduleFileExtensions config (#14369)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
### Features
|
||||
|
||||
- `[jest-config]` [**BREAKING**] Add `mts` and `cts` to default `moduleFileExtensions` config ([#14369](https://github.com/facebook/jest/pull/14369))
|
||||
- `[@jest/core]` [**BREAKING**] Group together open handles with the same stack trace ([#13417](https://github.com/jestjs/jest/pull/13417), & [#14543](https://github.com/jestjs/jest/pull/14543))
|
||||
- `[@jest/core, @jest/test-sequencer]` [**BREAKING**] Exposes `globalConfig` & `contexts` to `TestSequencer` ([#14535](https://github.com/jestjs/jest/pull/14535), & [#14543](https://github.com/jestjs/jest/pull/14543))
|
||||
- `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM to v22 ([#13825](https://github.com/jestjs/jest/pull/13825))
|
||||
|
||||
@@ -92,7 +92,7 @@ const {defaults} = require('jest-config');
|
||||
|
||||
/** @type {import('jest').Config} */
|
||||
const config = {
|
||||
moduleFileExtensions: [...defaults.moduleFileExtensions, 'mts', 'cts'],
|
||||
moduleDirectories: [...defaults.moduleDirectories, 'bower_components'],
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
@@ -103,7 +103,7 @@ import type {Config} from 'jest';
|
||||
import {defaults} from 'jest-config';
|
||||
|
||||
const config: Config = {
|
||||
moduleFileExtensions: [...defaults.moduleFileExtensions, 'mts'],
|
||||
moduleDirectories: [...defaults.moduleDirectories, 'bower_components'],
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -931,7 +931,7 @@ export default config;
|
||||
|
||||
### `moduleFileExtensions` \[array<string>]
|
||||
|
||||
Default: `["js", "mjs", "cjs", "jsx", "ts", "tsx", "json", "node"]`
|
||||
Default: `["js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx", "json", "node"]`
|
||||
|
||||
An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order.
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ exports[`--showConfig outputs config info and exits 1`] = `
|
||||
"cjs",
|
||||
"jsx",
|
||||
"ts",
|
||||
"mts",
|
||||
"cts",
|
||||
"tsx",
|
||||
"json",
|
||||
"node"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`testMatch should able to match file with cts and mts extension 1`] = `
|
||||
"Test Suites: 2 passed, 2 total
|
||||
Tests: 2 passed, 2 total
|
||||
Snapshots: 0 total
|
||||
Time: <<REPLACED>>
|
||||
Ran all test suites."
|
||||
`;
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 {extractSummary} from '../Utils';
|
||||
import runJest from '../runJest';
|
||||
|
||||
it('testMatch should able to match file with cts and mts extension', () => {
|
||||
const result = runJest('test-match-ts');
|
||||
expect(result.exitCode).toBe(0);
|
||||
const {summary} = extractSummary(result.stderr);
|
||||
expect(summary).toMatchSnapshot();
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
test('mts extension', () => {
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
test('cts extension', () => {
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"jest": {
|
||||
"testMatch": [
|
||||
"**/__tests__/*.?ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -202,6 +202,8 @@ const config: Config = {
|
||||
// "cjs",
|
||||
// "jsx",
|
||||
// "ts",
|
||||
// "mts",
|
||||
// "cts",
|
||||
// "tsx",
|
||||
// "json",
|
||||
// "node"
|
||||
@@ -404,6 +406,8 @@ const config = {
|
||||
// "cjs",
|
||||
// "jsx",
|
||||
// "ts",
|
||||
// "mts",
|
||||
// "cts",
|
||||
// "tsx",
|
||||
// "json",
|
||||
// "node"
|
||||
@@ -606,6 +610,8 @@ const config = {
|
||||
// "cjs",
|
||||
// "jsx",
|
||||
// "ts",
|
||||
// "mts",
|
||||
// "cts",
|
||||
// "tsx",
|
||||
// "json",
|
||||
// "node"
|
||||
|
||||
@@ -51,6 +51,8 @@ const defaultOptions: Config.DefaultOptions = {
|
||||
'cjs',
|
||||
'jsx',
|
||||
'ts',
|
||||
'mts',
|
||||
'cts',
|
||||
'tsx',
|
||||
'json',
|
||||
'node',
|
||||
|
||||
@@ -103,6 +103,8 @@ export const initialOptions: Config.InitialOptions = {
|
||||
'json',
|
||||
'jsx',
|
||||
'ts',
|
||||
'mts',
|
||||
'cts',
|
||||
'tsx',
|
||||
'node',
|
||||
],
|
||||
@@ -258,6 +260,8 @@ export const initialProjectOptions: Config.InitialProjectOptions = {
|
||||
'json',
|
||||
'jsx',
|
||||
'ts',
|
||||
'mts',
|
||||
'cts',
|
||||
'tsx',
|
||||
'node',
|
||||
],
|
||||
|
||||
@@ -1722,6 +1722,8 @@ describe('moduleFileExtensions', () => {
|
||||
'cjs',
|
||||
'jsx',
|
||||
'ts',
|
||||
'mts',
|
||||
'cts',
|
||||
'tsx',
|
||||
'json',
|
||||
'node',
|
||||
|
||||
Reference in New Issue
Block a user