Skip to content

Commit

Permalink
Merge branch 'main' into stekycz-v30-false-positive-failures
Browse files Browse the repository at this point in the history
  • Loading branch information
stekycz committed Sep 20, 2023
2 parents dbac9f9 + e7b1e75 commit 2f7d8a2
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions e2e/__tests__/__snapshots__/showConfig.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ exports[`--showConfig outputs config info and exits 1`] = `
"cjs",
"jsx",
"ts",
"mts",
"cts",
"tsx",
"json",
"node"
Expand Down
9 changes: 9 additions & 0 deletions e2e/__tests__/__snapshots__/testMatchTs.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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."
`;
16 changes: 16 additions & 0 deletions e2e/__tests__/testMatchTs.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
10 changes: 10 additions & 0 deletions e2e/test-match-ts/__tests__/sample-suite.mts
Original file line number Diff line number Diff line change
@@ -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);
});
10 changes: 10 additions & 0 deletions e2e/test-match-ts/__tests__/sample-suite2.cts
Original file line number Diff line number Diff line change
@@ -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);
});
7 changes: 7 additions & 0 deletions e2e/test-match-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"jest": {
"testMatch": [
"**/__tests__/*.?ts"
]
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
"babel-jest": "workspace:*",
"babel-loader": "^8.2.3",
"babel-loader": "^9.0.0",
"camelcase": "^6.2.0",
"chalk": "^4.0.0",
"chokidar": "^3.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ const config: Config = {
// "cjs",
// "jsx",
// "ts",
// "mts",
// "cts",
// "tsx",
// "json",
// "node"
Expand Down Expand Up @@ -404,6 +406,8 @@ const config = {
// "cjs",
// "jsx",
// "ts",
// "mts",
// "cts",
// "tsx",
// "json",
// "node"
Expand Down Expand Up @@ -606,6 +610,8 @@ const config = {
// "cjs",
// "jsx",
// "ts",
// "mts",
// "cts",
// "tsx",
// "json",
// "node"
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-config/src/Defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const defaultOptions: Config.DefaultOptions = {
'cjs',
'jsx',
'ts',
'mts',
'cts',
'tsx',
'json',
'node',
Expand Down
4 changes: 4 additions & 0 deletions packages/jest-config/src/ValidConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export const initialOptions: Config.InitialOptions = {
'json',
'jsx',
'ts',
'mts',
'cts',
'tsx',
'node',
],
Expand Down Expand Up @@ -258,6 +260,8 @@ export const initialProjectOptions: Config.InitialProjectOptions = {
'json',
'jsx',
'ts',
'mts',
'cts',
'tsx',
'node',
],
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-config/src/__tests__/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,8 @@ describe('moduleFileExtensions', () => {
'cjs',
'jsx',
'ts',
'mts',
'cts',
'tsx',
'json',
'node',
Expand Down
45 changes: 4 additions & 41 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2945,7 +2945,7 @@ __metadata:
ansi-regex: ^5.0.1
ansi-styles: ^5.0.0
babel-jest: "workspace:*"
babel-loader: ^8.2.3
babel-loader: ^9.0.0
camelcase: ^6.2.0
chalk: ^4.0.0
chokidar: ^3.3.0
Expand Down Expand Up @@ -6486,22 +6486,7 @@ __metadata:
languageName: unknown
linkType: soft

"babel-loader@npm:^8.2.3":
version: 8.3.0
resolution: "babel-loader@npm:8.3.0"
dependencies:
find-cache-dir: ^3.3.1
loader-utils: ^2.0.0
make-dir: ^3.1.0
schema-utils: ^2.6.5
peerDependencies:
"@babel/core": ^7.0.0
webpack: ">=2"
checksum: d48bcf9e030e598656ad3ff5fb85967db2eaaf38af5b4a4b99d25618a2057f9f100e6b231af2a46c1913206db506115ca7a8cbdf52c9c73d767070dae4352ab5
languageName: node
linkType: hard

"babel-loader@npm:^9.1.3":
"babel-loader@npm:^9.0.0, babel-loader@npm:^9.1.3":
version: 9.1.3
resolution: "babel-loader@npm:9.1.3"
dependencies:
Expand Down Expand Up @@ -10184,17 +10169,6 @@ __metadata:
languageName: node
linkType: hard

"find-cache-dir@npm:^3.3.1":
version: 3.3.2
resolution: "find-cache-dir@npm:3.3.2"
dependencies:
commondir: ^1.0.1
make-dir: ^3.0.2
pkg-dir: ^4.1.0
checksum: 1e61c2e64f5c0b1c535bd85939ae73b0e5773142713273818cc0b393ee3555fb0fd44e1a5b161b8b6c3e03e98c2fcc9c227d784850a13a90a8ab576869576817
languageName: node
linkType: hard

"find-cache-dir@npm:^4.0.0":
version: 4.0.0
resolution: "find-cache-dir@npm:4.0.0"
Expand Down Expand Up @@ -13962,7 +13936,7 @@ __metadata:
languageName: node
linkType: hard

"make-dir@npm:^3.0.0, make-dir@npm:^3.0.2, make-dir@npm:^3.1.0":
"make-dir@npm:^3.0.0, make-dir@npm:^3.1.0":
version: 3.1.0
resolution: "make-dir@npm:3.1.0"
dependencies:
Expand Down Expand Up @@ -16638,7 +16612,7 @@ __metadata:
languageName: node
linkType: hard

"pkg-dir@npm:^4.1.0, pkg-dir@npm:^4.2.0":
"pkg-dir@npm:^4.2.0":
version: 4.2.0
resolution: "pkg-dir@npm:4.2.0"
dependencies:
Expand Down Expand Up @@ -18639,17 +18613,6 @@ __metadata:
languageName: node
linkType: hard

"schema-utils@npm:^2.6.5":
version: 2.7.1
resolution: "schema-utils@npm:2.7.1"
dependencies:
"@types/json-schema": ^7.0.5
ajv: ^6.12.4
ajv-keywords: ^3.5.2
checksum: 32c62fc9e28edd101e1bd83453a4216eb9bd875cc4d3775e4452b541908fa8f61a7bbac8ffde57484f01d7096279d3ba0337078e85a918ecbeb72872fb09fb2b
languageName: node
linkType: hard

"schema-utils@npm:^3.0.0, schema-utils@npm:^3.1.1, schema-utils@npm:^3.2.0":
version: 3.3.0
resolution: "schema-utils@npm:3.3.0"
Expand Down

0 comments on commit 2f7d8a2

Please sign in to comment.