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 b4c01e2
Show file tree
Hide file tree
Showing 76 changed files with 285 additions and 128 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
32 changes: 18 additions & 14 deletions CHANGELOG.md
Expand Up @@ -2,15 +2,19 @@

### Features

- `[@jest/core]` Instrument significant lifecycle events with [`performance.mark()`](https://nodejs.org/docs/latest-v16.x/api/perf_hooks.html#performancemarkname-options) ([#13859](https://github.com/facebook/jest/pull/13859))

### Fixes

- `[expect, @jest/expect]` Provide type of `actual` as a generic argument to `Matchers` to allow better-typed extensions ([#13848](https://github.com/facebook/jest/pull/13848))
- `[jest-circus]` Added explicit mention of test failing because `done()` is not being called in error message ([#13847](https://github.com/facebook/jest/pull/13847))
- `[jest-transform]` Downgrade `write-file-atomic` to v4 ([#13853](https://github.com/facebook/jest/pull/13853))
- `[jest-worker]` Ignore IPC messages not intended for Jest ([#13543](https://github.com/facebook/jest/pull/13543))

### Chore & Maintenance

- `[*]` make sure to exclude `.eslintcache` from published module ([#13832](https://github.com/facebook/jest/pull/13832))
- `[jest-transform]` Downgrade `write-file-atomic` to v4
- `[docs]` Cleanup incorrect links in CHANGELOG.md ([#13857](https://github.com/facebook/jest/pull/13857))

### Performance

Expand Down Expand Up @@ -294,7 +298,7 @@

### Fixes

- `[@jest/expect-utils]` Fix deep equality of ImmutableJS OrderedMaps ([#12763](https://github.com/facebook/jest/pull/12899))
- `[@jest/expect-utils]` Fix deep equality of ImmutableJS OrderedMaps ([#12899](https://github.com/facebook/jest/pull/12899))
- `[jest-docblock]` Handle multiline comments in parseWithComments ([#12845](https://github.com/facebook/jest/pull/12845))
- `[jest-mock]` Improve `spyOn` error messages ([#12901](https://github.com/facebook/jest/pull/12901))
- `[jest-runtime]` Correctly report V8 coverage with `resetModules: true` ([#12912](https://github.com/facebook/jest/pull/12912))
Expand Down Expand Up @@ -772,7 +776,7 @@

### Features

- `[@jest/fake-timers]` Flush callbacks scheduled with `requestAnimationFrame` every 16ms when using legacy timers. ([#11523](https://github.com/facebook/jest/pull/11567))
- `[@jest/fake-timers]` Flush callbacks scheduled with `requestAnimationFrame` every 16ms when using legacy timers. ([#11567](https://github.com/facebook/jest/pull/11567))
- `[pretty-format]` Use `globalThis` (with polyfill if required) to bring support for esbuild's browser bundling mode ([#11569](https://github.com/facebook/jest/pull/11569))

### Fixes
Expand Down Expand Up @@ -859,7 +863,7 @@
- `[jest-runtime]` Detect reexports from CJS as named exports in ESM ([#10988](https://github.com/facebook/jest/pull/10988))
- `[jest-runtime]` Support for async code transformations ([#11191](https://github.com/facebook/jest/pull/11191) & [#11220](https://github.com/facebook/jest/pull/11220))
- `[jest-snapshot]` [**BREAKING**] Make prettier optional for inline snapshots - fall back to string replacement ([#7792](https://github.com/facebook/jest/pull/7792) & [#11192](https://github.com/facebook/jest/pull/11192))
- `[jest-snapshot]` [**BREAKING**] Run transforms over `snapshotResolver` ([#8751](https://github.com/facebook/jest/pull/8829))
- `[jest-snapshot]` [**BREAKING**] Run transforms over `snapshotResolver` ([#8829](https://github.com/facebook/jest/pull/8829))
- `[jest-transform]` Pass config options defined in Jest's config to transformer's `process` and `getCacheKey` functions ([#10926](https://github.com/facebook/jest/pull/10926))
- `[jest-transform]` Add support for transformers written in ESM ([#11163](https://github.com/facebook/jest/pull/11163))
- `[jest-transform]` [**BREAKING**] Do not export `ScriptTransformer` class, instead export the async function `createScriptTransformer` ([#11163](https://github.com/facebook/jest/pull/11163))
Expand Down Expand Up @@ -1107,7 +1111,7 @@

- `[jest-core]` Don't report ELDHistogram as open handle ([#10417](https://github.com/facebook/jest/pull/10417))
- `[jest-matcher-utils]` Fix diffing object contain readonly symbol key object ([#10414](https://github.com/facebook/jest/pull/10414))
- `[jest-reporters]` Fixes notify reporter on Linux (using notify-send) ([#10393](https://github.com/facebook/jest/pull/10400))
- `[jest-reporters]` Fixes notify reporter on Linux (using notify-send) ([#10400](https://github.com/facebook/jest/pull/10400))
- `[jest-snapshot]` Correctly handles arrays and property matchers in snapshots ([#10404](https://github.com/facebook/jest/pull/10404))

## 26.4.0
Expand Down Expand Up @@ -1156,7 +1160,7 @@
- `[jest-haste-map]` Watchman crawler now includes dotfiles ([#10075](https://github.com/facebook/jest/pull/10075))
- `[jest-worker]` Added support for workers to send custom messages to parent in jest-worker ([#10293](https://github.com/facebook/jest/pull/10293))
- `[jest-worker]` Support passing `resourceLimits` ([#10335](https://github.com/facebook/jest/pull/10335))
- `[pretty-format]` Added support for serializing custom elements (web components) ([#10217](https://github.com/facebook/jest/pull/10237))
- `[pretty-format]` Added support for serializing custom elements (web components) ([#10237](https://github.com/facebook/jest/pull/10237))

### Fixes

Expand Down Expand Up @@ -1573,7 +1577,7 @@
- `[expect]` Display equal values for ReturnedWith similar to CalledWith ([#8791](https://github.com/facebook/jest/pull/8791))
- `[expect, jest-snapshot]` Change color from green for some args in matcher hints ([#8812](https://github.com/facebook/jest/pull/8812))
- `[jest-snapshot]` Highlight substring differences when matcher fails, part 3 ([#8569](https://github.com/facebook/jest/pull/8569))
- `[jest-core]` Improve report when snapshots are obsolete ([#8448](https://github.com/facebook/jest/pull/8665))
- `[jest-core]` Improve report when snapshots are obsolete ([#8665](https://github.com/facebook/jest/pull/8665))
- `[jest-cli]` Improve chai support (with detailed output, to match jest exceptions) ([#8454](https://github.com/facebook/jest/pull/8454))
- `[*]` Manage the global timeout with `--testTimeout` command line argument. ([#8456](https://github.com/facebook/jest/pull/8456))
- `[pretty-format]` Render custom displayName of memoized components ([#8546](https://github.com/facebook/jest/pull/8546))
Expand Down Expand Up @@ -1862,7 +1866,7 @@ We skipped 24.2.0 because a draft was accidentally published. Please use `24.3.0
- `[jest-docblock]`: Migrate to TypeScript ([#7836](https://github.com/facebook/jest/pull/7836))
- `[jest-each]`: Migrate to Typescript ([#8007](https://github.com/facebook/jest/pull/8007))
- `[jest-each]`: Refactor into multiple files with better types ([#8018](https://github.com/facebook/jest/pull/8018))
- `[jest-environment-jsdom]`: Migrate to TypeScript ([#7985](https://github.com/facebook/jest/pull/8003))
- `[jest-environment-jsdom]`: Migrate to TypeScript ([#8003](https://github.com/facebook/jest/pull/8003))
- `[jest-environment-node]`: Migrate to TypeScript ([#7985](https://github.com/facebook/jest/pull/7985))
- `[jest-get-type]`: Migrate to TypeScript ([#7818](https://github.com/facebook/jest/pull/7818))
- `[jest-haste-map]`: Migrate to TypeScript ([#7854](https://github.com/facebook/jest/pull/7854), [#7951](https://github.com/facebook/jest/pull/7951))
Expand All @@ -1885,7 +1889,7 @@ We skipped 24.2.0 because a draft was accidentally published. Please use `24.3.0
- `[jest-watcher]`: Migrate to TypeScript ([#7843](https://github.com/facebook/jest/pull/7843))
- `[jest-worker]`: Migrate to TypeScript ([#7853](https://github.com/facebook/jest/pull/7853))
- `[jest]`: Migrate to TypeScript ([#8024](https://github.com/facebook/jest/pull/8024))
- `[pretty-format]`: Migrate to TypeScript ([#7809](https://github.com/facebook/jest/pull/7809), [#7809](https://github.com/facebook/jest/pull/7972))
- `[pretty-format]`: Migrate to TypeScript ([#7809](https://github.com/facebook/jest/pull/7809), [#7972](https://github.com/facebook/jest/pull/7972))

### Performance

Expand Down Expand Up @@ -2179,7 +2183,7 @@ We skipped 24.2.0 because a draft was accidentally published. Please use `24.3.0
- `[jest-jasmine2]` Use prettier through `require` instead of `localRequire`. Fixes `matchInlineSnapshot` where prettier dependencies like `path` and `fs` are mocked with `jest.mock`. ([#6776](https://github.com/facebook/jest/pull/6776))
- `[docs]` Fix contributors link ([#6711](https://github.com/facebook/jest/pull/6711))
- `[website]` Fix website versions page to link to correct language ([#6734](https://github.com/facebook/jest/pull/6734))
- `[expect]` Update `toContain` suggestion to contain equal message ([#6792](https://github.com/facebook/jest/pull/6810))
- `[expect]` Update `toContain` suggestion to contain equal message ([#6810](https://github.com/facebook/jest/pull/6810))

## 23.4.1

Expand Down Expand Up @@ -2320,7 +2324,7 @@ We skipped 24.2.0 because a draft was accidentally published. Please use `24.3.0
- `[jest-runtime]` Prevent modules from marking themselves as their own parent ([#5235](https://github.com/facebook/jest/issues/5235))
- `[jest-mock]` Add support for auto-mocking generator functions ([#5983](https://github.com/facebook/jest/pull/5983))
- `[expect]` Add support for async matchers ([#5919](https://github.com/facebook/jest/pull/5919))
- `[expect]` Suggest toContainEqual ([#5948](https://github.com/facebook/jest/pull/5953))
- `[expect]` Suggest toContainEqual ([#5953](https://github.com/facebook/jest/pull/5953))
- `[jest-config]` Export Jest's default options ([#5948](https://github.com/facebook/jest/pull/5948))
- `[jest-editor-support]` Move `coverage` to `ProjectWorkspace.collectCoverage` ([#5929](https://github.com/facebook/jest/pull/5929))
- `[jest-editor-support]` Add `coverage` option to runner ([#5836](https://github.com/facebook/jest/pull/5836))
Expand Down Expand Up @@ -2398,7 +2402,7 @@ We skipped 24.2.0 because a draft was accidentally published. Please use `24.3.0
- `[docs]` Add explanation on how to mock methods not implemented in JSDOM
- `[jest-jasmine2]` Simplify `Env.execute` and TreeProcessor to setup and clean resources for the top suite the same way as for all of the children suites ([#5885](https://github.com/facebook/jest/pull/5885))
- `[babel-jest]` [**BREAKING**] Always return object from transformer ([#5991](https://github.com/facebook/jest/pull/5991))
- `[*]` Run Prettier on compiled output ([#5858](https://github.com/facebook/jest/pull/3497))
- `[*]` Run Prettier on compiled output ([#5858](https://github.com/facebook/jest/pull/5858))
- `[jest-cli]` Add fileChange hook for plugins ([#5708](https://github.com/facebook/jest/pull/5708))
- `[docs]` Add docs on using `jest.mock(...)` ([#5648](https://github.com/facebook/jest/pull/5648))
- `[docs]` Mention Jest Puppeteer Preset ([#5722](https://github.com/facebook/jest/pull/5722))
Expand Down Expand Up @@ -2484,7 +2488,7 @@ We skipped 24.2.0 because a draft was accidentally published. Please use `24.3.0
### Fixes

- `[babel-jest]` Revert "Remove retainLines from babel-jest" ([#5496](https://github.com/facebook/jest/pull/5496))
- `[jest-docblock]` Support multiple of the same `@pragma`. ([#5154](https://github.com/facebook/jest/pull/5502))
- `[jest-docblock]` Support multiple of the same `@pragma`. ([#5502](https://github.com/facebook/jest/pull/5502))

### Features

Expand Down Expand Up @@ -2668,7 +2672,7 @@ We skipped 24.2.0 because a draft was accidentally published. Please use `24.3.0
- `[pretty-format]` Fix errors when identity-obj-proxy mocks CSS Modules ([#4935](https://github.com/facebook/jest/pull/4935))
- `[babel-jest]` Fix support for namespaced babel version 7 ([#4918](https://github.com/facebook/jest/pull/4918))
- `[expect]` fix .toThrow for promises ([#4884](https://github.com/facebook/jest/pull/4884))
- `[jest-docblock]` pragmas should preserve urls ([#4837](https://github.com/facebook/jest/pull/4629))
- `[jest-docblock]` pragmas should preserve urls ([#4837](https://github.com/facebook/jest/pull/4837))
- `[jest-cli]` Check if `npm_lifecycle_script` calls Jest directly ([#4629](https://github.com/facebook/jest/pull/4629))
- `[jest-cli]` Fix --showConfig to show all configs ([#4494](https://github.com/facebook/jest/pull/4494))
- `[jest-cli]` Throw if `maxWorkers` doesn't have a value ([#4591](https://github.com/facebook/jest/pull/4591))
Expand Down
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"}]
}

0 comments on commit b4c01e2

Please sign in to comment.