Skip to content

Commit 78a86c6

Browse files
authored
Merge branch 'main' into jest-globals-per-file
2 parents a46b5c0 + 7745acd commit 78a86c6

File tree

19 files changed

+159
-140
lines changed

19 files changed

+159
-140
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- `[jest-runtime]` Importing from `@jest/globals` in more than one file no longer breaks relative paths ([#15772](https://github.com/jestjs/jest/issues/15772))
66

7+
# Chore
8+
9+
- `[expect]` Update docblock for `toContain()` to display info on substring check ([#15789](https://github.com/jestjs/jest/pull/15789))
10+
711
## 30.0.5
812

913
### Features

docs/GettingStarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Jest is not supported by Vite due to incompatibilities with the Vite [plugin sys
133133

134134
There are examples for Jest integration with Vite in the [vite-jest](https://github.com/sodatea/vite-jest) library. However, this library is not compatible with versions of Vite later than 2.4.2.
135135

136-
One alternative is [Vitest](https://vitest.dev/) which has an API compatible Jest.
136+
One alternative is [Vitest](https://vitest.dev/) which has an API that is compatible with Jest.
137137

138138
### Using Parcel
139139

e2e/__tests__/tsIntegration.test.ts

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77

88
import * as path from 'path';
99
import {cleanup, writeFiles} from '../Utils';
10-
import runJest, {getConfig} from '../runJest';
10+
import runJest, {getConfig, useNativeTypeScript} from '../runJest';
1111

1212
const DIR = path.resolve(__dirname, '../ts-node-integration');
1313

1414
beforeEach(() => cleanup(DIR));
1515
afterAll(() => cleanup(DIR));
1616

17+
// Node.js's builtin TypeScript support doesn't do type checking, so skip tests
18+
// that validate type-checking behavior.
19+
const testIfTsLoader = useNativeTypeScript ? test.skip : test;
20+
1721
describe('when `Config` type is imported from "@jest/types"', () => {
1822
test('with object config exported from TS file', () => {
1923
writeFiles(DIR, {
@@ -93,7 +97,7 @@ describe('when `Config` type is imported from "@jest/types"', () => {
9397
expect(globalConfig.verbose).toBe(true);
9498
});
9599

96-
test('throws if type errors are encountered', () => {
100+
testIfTsLoader('throws if type errors are encountered', () => {
97101
writeFiles(DIR, {
98102
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
99103
'jest.config.ts': `
@@ -247,24 +251,27 @@ describe('when `Config` type is imported from "@jest/types"', () => {
247251
expect(globalConfig.verbose).toBe(true);
248252
});
249253

250-
test('throws if type errors are encountered when package.json#type=module', () => {
251-
writeFiles(DIR, {
252-
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
253-
'jest.config.ts': `
254+
testIfTsLoader(
255+
'throws if type errors are encountered when package.json#type=module',
256+
() => {
257+
writeFiles(DIR, {
258+
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
259+
'jest.config.ts': `
254260
import type {Config} from '@jest/types';
255261
const config: Config.InitialOptions = {testTimeout: '10000'};
256262
export default config;
257263
`,
258-
'package.json': '{"type": "module"}',
259-
});
264+
'package.json': '{"type": "module"}',
265+
});
260266

261-
const {stderr, exitCode} = runJest(DIR);
267+
const {stderr, exitCode} = runJest(DIR);
262268

263-
expect(stderr).toMatch(
264-
"jest.config.ts(2,40): error TS2322: Type 'string' is not assignable to type 'number'.",
265-
);
266-
expect(exitCode).toBe(1);
267-
});
269+
expect(stderr).toMatch(
270+
"jest.config.ts(2,40): error TS2322: Type 'string' is not assignable to type 'number'.",
271+
);
272+
expect(exitCode).toBe(1);
273+
},
274+
);
268275

269276
test('throws if syntax errors are encountered when package.json#type=module', () => {
270277
writeFiles(DIR, {
@@ -403,7 +410,7 @@ describe('when `Config` type is imported from "jest"', () => {
403410
expect(globalConfig.verbose).toBe(true);
404411
});
405412

406-
test('throws if type errors are encountered', () => {
413+
testIfTsLoader('throws if type errors are encountered', () => {
407414
writeFiles(DIR, {
408415
'__tests__/dummy.test.js': "test('dummy', () => expect(123).toBe(123));",
409416
'jest.config.ts': `
@@ -557,24 +564,27 @@ describe('when `Config` type is imported from "jest"', () => {
557564
expect(globalConfig.verbose).toBe(true);
558565
});
559566

560-
test('throws if type errors are encountered when package.json#type=module', () => {
561-
writeFiles(DIR, {
562-
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
563-
'jest.config.ts': `
567+
testIfTsLoader(
568+
'throws if type errors are encountered when package.json#type=module',
569+
() => {
570+
writeFiles(DIR, {
571+
'__tests__/dummy.test.js': "test('dummy', () => expect(12).toBe(12));",
572+
'jest.config.ts': `
564573
import type {Config} from 'jest';
565574
const config: Config = {testTimeout: '10000'};
566575
export default config;
567576
`,
568-
'package.json': '{"type": "module"}',
569-
});
577+
'package.json': '{"type": "module"}',
578+
});
570579

571-
const {stderr, exitCode} = runJest(DIR);
580+
const {stderr, exitCode} = runJest(DIR);
572581

573-
expect(stderr).toMatch(
574-
"jest.config.ts(2,25): error TS2322: Type 'string' is not assignable to type 'number'.",
575-
);
576-
expect(exitCode).toBe(1);
577-
});
582+
expect(stderr).toMatch(
583+
"jest.config.ts(2,25): error TS2322: Type 'string' is not assignable to type 'number'.",
584+
);
585+
expect(exitCode).toBe(1);
586+
},
587+
);
578588

579589
test('throws if syntax errors are encountered when package.json#type=module', () => {
580590
writeFiles(DIR, {

e2e/__tests__/typescriptConfigFile.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
import {tmpdir} from 'os';
99
import * as path from 'path';
10-
import * as semver from 'semver';
1110
import {onNodeVersions} from '@jest/test-utils';
1211
import {cleanup, writeFiles} from '../Utils';
13-
import runJest, {getConfig} from '../runJest';
12+
import runJest, {getConfig, useNativeTypeScript} from '../runJest';
1413

1514
const DIR = path.resolve(tmpdir(), 'typescript-config-file');
16-
const useNativeTypeScript = semver.satisfies(process.versions.node, '>=23.6.0');
1715
const importFileExtension = useNativeTypeScript ? '.ts' : '';
1816

1917
beforeEach(() => cleanup(DIR));

e2e/custom-reporters/reporters/AssertionCountsReporter.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ class AssertionCountsReporter {
1818
}
1919
}
2020
onTestCaseResult(test, testCaseResult) {
21-
const difference = new Date(
22-
Date.now() - testCaseResult.startedAt,
23-
).getDate();
21+
const difference = Date.now() - testCaseResult.startedAt;
22+
const sameDay = difference >= 0 && difference < 24 * 60 * 60 * 1000;
2423
console.log(
2524
`onTestCaseResult: ${testCaseResult.title}, ` +
26-
`started: ${difference === 1 ? 'today' : 'invalid'}, ` +
25+
`started: ${sameDay ? 'today' : 'invalid'}, ` +
2726
`status: ${testCaseResult.status}, ` +
2827
`numExpectations: ${testCaseResult.numPassingAsserts}`,
2928
);

e2e/runJest.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ import {stripVTControlCharacters as stripAnsi} from 'util';
1212
import dedent from 'dedent';
1313
import execa from 'execa';
1414
import * as fs from 'graceful-fs';
15+
import * as semver from 'semver';
1516
import {TestPathPatterns} from '@jest/pattern';
1617
import type {FormattedTestResults} from '@jest/test-result';
1718
import {normalizeIcons} from '@jest/test-utils';
1819
import type {Config} from '@jest/types';
1920
import {ErrorWithStack} from 'jest-util';
2021

22+
export const useNativeTypeScript = semver.satisfies(
23+
process.versions.node,
24+
'^22.18.0 || >=23.6.0',
25+
);
26+
2127
const JEST_PATH = path.resolve(__dirname, '../packages/jest-cli/bin/jest.js');
2228

2329
type RunJestOptions = {

examples/angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"core-js": "^3.2.1",
1616
"rxjs": "^7.8.2",
1717
"tslib": "^2.0.0",
18-
"typescript": "^5.0.4",
18+
"typescript": "^5.8.3",
1919
"zone.js": "~0.11.8"
2020
},
2121
"devDependencies": {

examples/expect-extend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"babel-jest": "workspace:*",
1111
"expect": "workspace:*",
1212
"jest": "workspace:*",
13-
"typescript": "^5.0.4"
13+
"typescript": "^5.8.3"
1414
},
1515
"scripts": {
1616
"test": "jest"

examples/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dependencies": {
66
"react": "18.3.1",
77
"react-dom": "18.3.1",
8-
"typescript": "^5.0.4"
8+
"typescript": "^5.8.3"
99
},
1010
"devDependencies": {
1111
"@babel/core": "^7.27.4",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
"tempy": "^1.0.1",
8080
"ts-node": "^10.5.0",
8181
"tstyche": "^4.0.0",
82-
"typescript": "^5.0.4",
83-
"typescript-eslint": "^8.33.1",
82+
"typescript": "^5.8.3",
83+
"typescript-eslint": "^8.38.0",
8484
"webpack": "^5.68.0",
8585
"webpack-node-externals": "^3.0.0",
8686
"which": "^4.0.0"

0 commit comments

Comments
 (0)