Skip to content

Commit

Permalink
Merge branch 'main' into downgrade-write-file-atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 7, 2023
2 parents 50c5dac + be501e1 commit 247e450
Show file tree
Hide file tree
Showing 76 changed files with 285 additions and 3,627 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.cjs
Expand Up @@ -235,6 +235,15 @@ module.exports = {
'jest/prefer-to-have-length': 'off',
},
},
// snapshot in an example needs to keep escapes
{
files: [
'**/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md/**',
],
rules: {
'no-useless-escape': 'off',
},
},

// snapshots in examples plus inline snapshots need to keep backtick
{
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/nodejs.yml
Expand Up @@ -82,6 +82,8 @@ jobs:
run: yarn lint
- name: run prettier
run: yarn lint:prettier:ci
- name: check changelog
run: yarn check-changelog
- name: check copyright headers
run: yarn check-copyright-headers

Expand Down
3,531 changes: 18 additions & 3,513 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/ExpectAPI.md
Expand Up @@ -1262,7 +1262,7 @@ These helper functions and properties can be found on `this` inside a custom tes

#### `this.equals(a, b, customTesters?)`

This is a deep-equality function that will return `true` if two objects have the same values (recursively). It optionally takes a list of custom equality testers to apply to the deep equality checks. If you use this function, pass through the custom testers your tester is given so further equality checks `equals` applies can also use custom testers the test author may have configured. See the example in the [Recursive custom equality testers][#recursivecustomequalitytesters] section for more details.
This is a deep-equality function that will return `true` if two objects have the same values (recursively). It optionally takes a list of custom equality testers to apply to the deep equality checks. If you use this function, pass through the custom testers your tester is given so further equality checks `equals` applies can also use custom testers the test author may have configured. See the example in the [Recursive custom equality testers](#recursive-custom-equality-testers) section for more details.

#### Matchers vs Testers

Expand Down
2 changes: 1 addition & 1 deletion docs/Webpack.md
Expand Up @@ -202,7 +202,7 @@ For more complex webpack configurations, you may also want to investigate projec
In addition to installing `babel-jest` as described earlier, you'll need to add `@babel/preset-env` like so:

```bash npm2yarn
npm install --save-dev @babel/preset-env
npm install --save-dev @babel/preset-env
```

Then, you'll want to configure Babel as follows:
Expand Down
3 changes: 2 additions & 1 deletion e2e/tsconfig.json
Expand Up @@ -3,5 +3,6 @@
"compilerOptions": {
"rootDir": "./"
},
"include": ["./**/*"]
"include": ["./**/*"],
"references": [{"path": "../packages/test-utils"}]
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -89,6 +89,7 @@
"build:js": "node ./scripts/build.mjs",
"build:ts": "node ./scripts/buildTs.mjs",
"bundle:ts": "node ./scripts/bundleTs.mjs",
"check-changelog": "node ./scripts/checkChangelog.mjs",
"check-copyright-headers": "node ./scripts/checkCopyrightHeaders.mjs",
"clean-all": "yarn clean-e2e && yarn build-clean && rimraf './packages/*/node_modules' && rimraf './node_modules'",
"clean-e2e": "node ./scripts/cleanE2e.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-jest/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
2 changes: 1 addition & 1 deletion packages/babel-jest/tsconfig.json
Expand Up @@ -7,5 +7,5 @@
"include": ["./src/**/*"],
"exclude": ["./**/__tests__/**/*"],
// TODO: include `babel-preset-jest` if it's ever in TS even though we don't care about its types
"references": [{"path": "../jest-transform"}, {"path": "../test-utils"}]
"references": [{"path": "../jest-transform"}]
}
2 changes: 1 addition & 1 deletion packages/expect/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/expect/tsconfig.json
Expand Up @@ -12,7 +12,6 @@
{"path": "../jest-get-type"},
{"path": "../jest-matcher-utils"},
{"path": "../jest-message-util"},
{"path": "../jest-util"},
{"path": "../test-utils"}
{"path": "../jest-util"}
]
}
2 changes: 1 addition & 1 deletion packages/jest-console/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/jest-console/tsconfig.json
Expand Up @@ -9,7 +9,6 @@
"references": [
{"path": "../jest-message-util"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../test-utils"}
{"path": "../jest-util"}
]
}
6 changes: 2 additions & 4 deletions packages/jest-core/src/__tests__/tsconfig.json
@@ -1,7 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"compilerOptions": {
"rootDir": "../"
},
"include": ["../**/*"]
"include": ["./**/*"],
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
11 changes: 11 additions & 0 deletions packages/jest-core/src/cli/index.ts
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import {performance} from 'perf_hooks';
import chalk = require('chalk');
import exit = require('exit');
import * as fs from 'graceful-fs';
Expand Down Expand Up @@ -41,6 +42,7 @@ export async function runCLI(
results: AggregatedResult;
globalConfig: Config.GlobalConfig;
}> {
performance.mark('jest/runCLI:start');
let results: AggregatedResult | undefined;

// If we output a JSON object, we can't write anything to stdout, since
Expand Down Expand Up @@ -133,6 +135,7 @@ export async function runCLI(
console.error(message);
}

performance.mark('jest/runCLI:end');
return {globalConfig, results};
}

Expand Down Expand Up @@ -173,6 +176,12 @@ const _run10000 = async (
// Queries to hg/git can take a while, so we need to start the process
// as soon as possible, so by the time we need the result it's already there.
const changedFilesPromise = getChangedFilesPromise(globalConfig, configs);
if (changedFilesPromise) {
performance.mark('jest/getChangedFiles:start');
changedFilesPromise.finally(() => {
performance.mark('jest/getChangedFiles:end');
});
}

// Filter may need to do an HTTP call or something similar to setup.
// We will wait on an async response from this before using the filter.
Expand Down Expand Up @@ -204,11 +213,13 @@ const _run10000 = async (
};
}

performance.mark('jest/buildContextsAndHasteMaps:start');
const {contexts, hasteMapInstances} = await buildContextsAndHasteMaps(
configs,
globalConfig,
outputStream,
);
performance.mark('jest/buildContextsAndHasteMaps:end');

globalConfig.watch || globalConfig.watchAll
? await runWatch(
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/lib/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../../"}]
"references": [{"path": "../../../"}, {"path": "../../../../test-utils"}]
}
16 changes: 16 additions & 0 deletions packages/jest-core/src/runJest.ts
Expand Up @@ -6,6 +6,7 @@
*/

import * as path from 'path';
import {performance} from 'perf_hooks';
import chalk = require('chalk');
import exit = require('exit');
import * as fs from 'graceful-fs';
Expand Down Expand Up @@ -179,6 +180,7 @@ export default async function runJest({

const searchSources = contexts.map(context => new SearchSource(context));

performance.mark('jest/getTestPaths:start');
const testRunData: TestRunData = await Promise.all(
contexts.map(async (context, index) => {
const searchSource = searchSources[index];
Expand All @@ -195,6 +197,7 @@ export default async function runJest({
return {context, matches};
}),
);
performance.mark('jest/getTestPaths:end');

if (globalConfig.shard) {
if (typeof sequencer.shard !== 'function') {
Expand Down Expand Up @@ -260,7 +263,9 @@ export default async function runJest({
}

if (hasTests) {
performance.mark('jest/globalSetup:start');
await runGlobalHook({allTests, globalConfig, moduleName: 'globalSetup'});
performance.mark('jest/globalSetup:end');
}

if (changedFilesPromise) {
Expand Down Expand Up @@ -289,14 +294,24 @@ export default async function runJest({
...testSchedulerContext,
});

// @ts-expect-error - second arg is unsupported (but harmless) in Node 14
performance.mark('jest/scheduleAndRun:start', {
detail: {numTests: allTests.length},
});
const results = await scheduler.scheduleTests(allTests, testWatcher);
performance.mark('jest/scheduleAndRun:start');

performance.mark('jest/cacheResults:start');
sequencer.cacheResults(allTests, results);
performance.mark('jest/cacheResults:end');

if (hasTests) {
performance.mark('jest/globalTeardown:start');
await runGlobalHook({allTests, globalConfig, moduleName: 'globalTeardown'});
performance.mark('jest/globalTeardown:end');
}

performance.mark('jest/processResults:start');
await processResults(results, {
collectHandles,
json: globalConfig.json,
Expand All @@ -305,4 +320,5 @@ export default async function runJest({
outputStream,
testResultsProcessor: globalConfig.testResultsProcessor,
});
performance.mark('jest/processResults:end');
}
3 changes: 1 addition & 2 deletions packages/jest-core/tsconfig.json
Expand Up @@ -26,7 +26,6 @@
{"path": "../jest-util"},
{"path": "../jest-validate"},
{"path": "../jest-watcher"},
{"path": "../pretty-format"},
{"path": "../test-utils"}
{"path": "../pretty-format"}
]
}
2 changes: 1 addition & 1 deletion packages/jest-diff/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/jest-diff/tsconfig.json
Expand Up @@ -9,7 +9,6 @@
"references": [
{"path": "../diff-sequences"},
{"path": "../jest-get-type"},
{"path": "../pretty-format"},
{"path": "../test-utils"}
{"path": "../pretty-format"}
]
}
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/jest-environment-jsdom/tsconfig.json
Expand Up @@ -11,7 +11,6 @@
{"path": "../jest-fake-timers"},
{"path": "../jest-mock"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../test-utils"}
{"path": "../jest-util"}
]
}
2 changes: 1 addition & 1 deletion packages/jest-environment-node/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/jest-environment-node/tsconfig.json
Expand Up @@ -11,7 +11,6 @@
{"path": "../jest-fake-timers"},
{"path": "../jest-mock"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../test-utils"}
{"path": "../jest-util"}
]
}
2 changes: 1 addition & 1 deletion packages/jest-fake-timers/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/jest-fake-timers/tsconfig.json
Expand Up @@ -11,7 +11,6 @@
{"path": "../jest-message-util"},
{"path": "../jest-mock"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../test-utils"}
{"path": "../jest-util"}
]
}
1 change: 0 additions & 1 deletion packages/jest-haste-map/package.json
Expand Up @@ -30,7 +30,6 @@
"walker": "^1.0.8"
},
"devDependencies": {
"@jest/test-utils": "workspace:^",
"@types/fb-watchman": "^2.0.0",
"@types/micromatch": "^4.0.1",
"slash": "^3.0.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/jest-haste-map/tsconfig.json
Expand Up @@ -10,7 +10,6 @@
{"path": "../jest-regex-util"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../jest-worker"},
{"path": "../test-utils"}
{"path": "../jest-worker"}
]
}
2 changes: 1 addition & 1 deletion packages/jest-matcher-utils/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/jest-matcher-utils/tsconfig.json
Expand Up @@ -10,7 +10,6 @@
"references": [
{"path": "../jest-diff"},
{"path": "../jest-get-type"},
{"path": "../pretty-format"},
{"path": "../test-utils"}
{"path": "../pretty-format"}
]
}
2 changes: 1 addition & 1 deletion packages/jest-reporters/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/jest-reporters/tsconfig.json
Expand Up @@ -14,7 +14,6 @@
{"path": "../jest-transform"},
{"path": "../jest-types"},
{"path": "../jest-util"},
{"path": "../jest-worker"},
{"path": "../test-utils"}
{"path": "../jest-worker"}
]
}
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
3 changes: 1 addition & 2 deletions packages/jest-resolve-dependencies/tsconfig.json
Expand Up @@ -12,7 +12,6 @@
{"path": "../jest-resolve"},
{"path": "../jest-runtime"},
{"path": "../jest-snapshot"},
{"path": "../jest-types"},
{"path": "../test-utils"}
{"path": "../jest-types"}
]
}
1 change: 1 addition & 0 deletions packages/jest-runner/package.json
Expand Up @@ -40,6 +40,7 @@
"source-map-support": "0.5.13"
},
"devDependencies": {
"@jest/test-utils": "workspace:^",
"@tsd/typescript": "^4.9.0",
"@types/exit": "^0.1.30",
"@types/graceful-fs": "^4.1.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runner/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/__tests__/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.test.json",
"include": ["./**/*"],
"references": [{"path": "../../"}]
"references": [{"path": "../../"}, {"path": "../../../test-utils"}]
}

0 comments on commit 247e450

Please sign in to comment.