diff --git a/.github/ISSUE_TEMPLATE/documentation.yaml b/.github/ISSUE_TEMPLATE/documentation.yaml new file mode 100644 index 000000000000..5532452ffc82 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yaml @@ -0,0 +1,30 @@ +name: Documentation 📖 +description: Submit a request to add or update documentation +title: '[Docs]: ' +labels: ['Documentation :book:'] +body: + - type: markdown + attributes: + value: | + ### Thank you for helping us improve our documentation! + + Please be sure you are looking at [the latest version of the documentation](https://jestjs.io/docs) before opening an issue here. + - type: textarea + id: links + attributes: + label: Page(s) + description: | + Links to one or more documentation pages that should be modified. + If you are reporting an issue with a specific section of a page, try to link directly to the nearest anchor. + If you are suggesting that a new page be created, link to the parent of the proposed page. + validations: + required: true + - type: textarea + id: description + attributes: + label: Description + description: | + Describe the change you are requesting. + If the issue pertains to a single function or matcher, be sure to specify the entire call signature. + validations: + required: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 6685daf48a2d..a5942b0cb075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,21 @@ ### Fixes + ### Chore & Maintenance +## 29.6.4 + +### Fixes + +- `[jest-core]` Fix typo in `scheduleAndRun` performance marker ([#14434](https://github.com/jestjs/jest/pull/14434)) +- `[jest-environment-node]` Make sure `atob` and `btoa` are writeable in Node 20 ([#14446](https://github.com/jestjs/jest/pull/14446)) +- `[jest-worker]` Additional error wrapper for `parentPort.postMessage` to fix unhandled `DataCloneError`. ([#14437](https://github.com/jestjs/jest/pull/14437)) + ## 29.6.3 +### Fixes + - `[expect, @jest/expect-utils]` `ObjectContaining` support `sumbol` as key ([#14414](https://github.com/jestjs/jest/pull/14414)) - `[expect]` Remove `@types/node` from dependencies ([#14385](https://github.com/jestjs/jest/pull/14385)) - `[jest-core]` Use workers in watch mode by default to avoid crashes ([#14059](https://github.com/facebook/jest/pull/14059) & [#14085](https://github.com/facebook/jest/pull/14085)). diff --git a/docs/Configuration.md b/docs/Configuration.md index 4e23e314b103..1a50070df269 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1401,7 +1401,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments: ```js title="custom-reporter.js" class CustomReporter { @@ -1430,6 +1430,12 @@ class CustomReporter { module.exports = CustomReporter; ``` +:::note + +For the full list of hooks and argument types see the `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts). + +::: + ### `resetMocks` \[boolean] Default: `false` diff --git a/docs/ManualMocks.md b/docs/ManualMocks.md index d166114387eb..7d7e9ab8f1d1 100644 --- a/docs/ManualMocks.md +++ b/docs/ManualMocks.md @@ -29,7 +29,7 @@ Scoped modules (also known as [scoped packages](https://docs.npmjs.com/cli/v6/us :::caution -If we want to mock Node's build-in modules (e.g.: `fs` or `path`), then explicitly calling e.g. `jest.mock('path')` is **required**, because build-in modules are not mocked by default. +If we want to mock Node's built-in modules (e.g.: `fs` or `path`), then explicitly calling e.g. `jest.mock('path')` is **required**, because built-in modules are not mocked by default. ::: @@ -110,7 +110,7 @@ fs.readdirSync = readdirSync; module.exports = fs; ``` -Now we write our test. In this case `jest.mock('fs')` must be called explicitly, because `fs` is Node’s build-in module: +Now we write our test. In this case `jest.mock('fs')` must be called explicitly, because `fs` is Node’s built-in module: ```javascript title="__tests__/FileSummarizer-test.js" 'use strict'; diff --git a/e2e/override-globals/__tests__/index.js b/e2e/override-globals/__tests__/index.js index 59448c4a07a4..91f6dd01c9db 100644 --- a/e2e/override-globals/__tests__/index.js +++ b/e2e/override-globals/__tests__/index.js @@ -27,4 +27,13 @@ describe('parent', () => { }, 10); }); }); + + it('can override atob and btoa', () => { + // eslint-disable-next-line no-restricted-globals + global.atob = () => 'hello'; + // eslint-disable-next-line no-restricted-globals + global.btoa = () => 'there'; + + expect(`${atob()} ${btoa()}`).toBe('hello there'); + }); }); diff --git a/lerna.json b/lerna.json index 9247a8fa99f6..e1b887c7f17b 100644 --- a/lerna.json +++ b/lerna.json @@ -8,5 +8,5 @@ "syncWorkspaceLock": true } }, - "version": "29.6.3" + "version": "29.6.4" } diff --git a/packages/babel-jest/package.json b/packages/babel-jest/package.json index 4e2159511c03..e986e7d6ad16 100644 --- a/packages/babel-jest/package.json +++ b/packages/babel-jest/package.json @@ -1,7 +1,7 @@ { "name": "babel-jest", "description": "Jest plugin to use babel for transformation.", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/expect-utils/package.json b/packages/expect-utils/package.json index efd3dc28339b..d5103feafb41 100644 --- a/packages/expect-utils/package.json +++ b/packages/expect-utils/package.json @@ -1,6 +1,6 @@ { "name": "@jest/expect-utils", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/expect/package.json b/packages/expect/package.json index 55e9f07da901..7db38a0a045f 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -1,6 +1,6 @@ { "name": "expect", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index 701df52e3a06..e628d65b5fdc 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -1,6 +1,6 @@ { "name": "jest-circus", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index 5c797662fb44..067c0744072a 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -1,7 +1,7 @@ { "name": "jest-cli", "description": "Delightful JavaScript Testing.", - "version": "29.6.3", + "version": "29.6.4", "main": "./build/index.js", "types": "./build/index.d.ts", "exports": { diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index a6f459b33349..4157be4645de 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -1,6 +1,6 @@ { "name": "jest-config", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-console/package.json b/packages/jest-console/package.json index 0fd766e197e2..7131d13a3062 100644 --- a/packages/jest-console/package.json +++ b/packages/jest-console/package.json @@ -1,6 +1,6 @@ { "name": "@jest/console", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index eab191df3de6..d0eded4aa7f5 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -1,7 +1,7 @@ { "name": "@jest/core", "description": "Delightful JavaScript Testing.", - "version": "29.6.3", + "version": "29.6.4", "main": "./build/index.js", "types": "./build/index.d.ts", "exports": { diff --git a/packages/jest-core/src/runJest.ts b/packages/jest-core/src/runJest.ts index b3098231c32c..45b31137d292 100644 --- a/packages/jest-core/src/runJest.ts +++ b/packages/jest-core/src/runJest.ts @@ -299,7 +299,7 @@ export default async function runJest({ detail: {numTests: allTests.length}, }); const results = await scheduler.scheduleTests(allTests, testWatcher); - performance.mark('jest/scheduleAndRun:start'); + performance.mark('jest/scheduleAndRun:end'); performance.mark('jest/cacheResults:start'); sequencer.cacheResults(allTests, results); diff --git a/packages/jest-diff/package.json b/packages/jest-diff/package.json index 0722c029965f..20272a7b67eb 100644 --- a/packages/jest-diff/package.json +++ b/packages/jest-diff/package.json @@ -1,6 +1,6 @@ { "name": "jest-diff", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index d8f8cf35e84a..44046683f5a1 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -1,6 +1,6 @@ { "name": "jest-environment-jsdom", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-environment-node/package.json b/packages/jest-environment-node/package.json index 5e38ba41cbf9..92090fe9757e 100644 --- a/packages/jest-environment-node/package.json +++ b/packages/jest-environment-node/package.json @@ -1,6 +1,6 @@ { "name": "jest-environment-node", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-environment-node/src/index.ts b/packages/jest-environment-node/src/index.ts index 1b387aaffee5..13be75062742 100644 --- a/packages/jest-environment-node/src/index.ts +++ b/packages/jest-environment-node/src/index.ts @@ -27,6 +27,7 @@ const denyList = new Set([ 'GLOBAL', 'root', 'global', + 'globalThis', 'Buffer', 'ArrayBuffer', 'Uint8Array', @@ -34,9 +35,11 @@ const denyList = new Set([ 'jest-symbol-do-not-touch', ]); +type GlobalProperties = Array; + const nodeGlobals = new Map( - Object.getOwnPropertyNames(globalThis) - .filter(global => !denyList.has(global)) + (Object.getOwnPropertyNames(globalThis) as GlobalProperties) + .filter(global => !denyList.has(global as string)) .map(nodeGlobalsKey => { const descriptor = Object.getOwnPropertyDescriptor( globalThis, @@ -76,7 +79,9 @@ export default class NodeEnvironment implements JestEnvironment { ) as Global.Global; this.global = global; - const contextGlobals = new Set(Object.getOwnPropertyNames(global)); + const contextGlobals = new Set( + Object.getOwnPropertyNames(global) as GlobalProperties, + ); for (const [nodeGlobalsKey, descriptor] of nodeGlobals) { if (!contextGlobals.has(nodeGlobalsKey)) { if (descriptor.configurable) { @@ -84,27 +89,24 @@ export default class NodeEnvironment implements JestEnvironment { configurable: true, enumerable: descriptor.enumerable, get() { - // @ts-expect-error: no index signature - const val = globalThis[nodeGlobalsKey] as unknown; + const value = globalThis[nodeGlobalsKey]; // override lazy getter Object.defineProperty(global, nodeGlobalsKey, { configurable: true, enumerable: descriptor.enumerable, - value: val, - writable: - descriptor.writable === true || - // Node 19 makes performance non-readable. This is probably not the correct solution. - nodeGlobalsKey === 'performance', + value, + writable: true, }); - return val; + + return value; }, - set(val: unknown) { + set(value: unknown) { // override lazy getter Object.defineProperty(global, nodeGlobalsKey, { configurable: true, enumerable: descriptor.enumerable, - value: val, + value, writable: true, }); }, diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json index b6f25ec5f97f..dd8fd5b493a2 100644 --- a/packages/jest-environment/package.json +++ b/packages/jest-environment/package.json @@ -1,6 +1,6 @@ { "name": "@jest/environment", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-expect/package.json b/packages/jest-expect/package.json index 5c61eb63b37d..251fbf73ce09 100644 --- a/packages/jest-expect/package.json +++ b/packages/jest-expect/package.json @@ -1,6 +1,6 @@ { "name": "@jest/expect", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index df04e61954ed..0ec6870b856c 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -1,6 +1,6 @@ { "name": "@jest/fake-timers", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-globals/package.json b/packages/jest-globals/package.json index 29ddf25491da..348fc7311918 100644 --- a/packages/jest-globals/package.json +++ b/packages/jest-globals/package.json @@ -1,6 +1,6 @@ { "name": "@jest/globals", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index 5fb5d70866ce..c9efad3cb459 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -1,6 +1,6 @@ { "name": "jest-haste-map", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-jasmine2/package.json b/packages/jest-jasmine2/package.json index acaddf6704b8..b0af3e11a6f0 100644 --- a/packages/jest-jasmine2/package.json +++ b/packages/jest-jasmine2/package.json @@ -1,6 +1,6 @@ { "name": "jest-jasmine2", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-matcher-utils/package.json b/packages/jest-matcher-utils/package.json index 6a8efd646c0c..7461d736605b 100644 --- a/packages/jest-matcher-utils/package.json +++ b/packages/jest-matcher-utils/package.json @@ -1,7 +1,7 @@ { "name": "jest-matcher-utils", "description": "A set of utility functions for expect and related packages", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-phabricator/package.json b/packages/jest-phabricator/package.json index abae95b9bab2..5b3a32ce29d9 100644 --- a/packages/jest-phabricator/package.json +++ b/packages/jest-phabricator/package.json @@ -1,6 +1,6 @@ { "name": "jest-phabricator", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index de915df4091f..dfb451305639 100644 --- a/packages/jest-repl/package.json +++ b/packages/jest-repl/package.json @@ -1,6 +1,6 @@ { "name": "jest-repl", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-reporters/package.json b/packages/jest-reporters/package.json index 4f5296ab00e1..5b065ba34b2b 100644 --- a/packages/jest-reporters/package.json +++ b/packages/jest-reporters/package.json @@ -1,7 +1,7 @@ { "name": "@jest/reporters", "description": "Jest's reporters", - "version": "29.6.3", + "version": "29.6.4", "main": "./build/index.js", "types": "./build/index.d.ts", "exports": { diff --git a/packages/jest-resolve-dependencies/package.json b/packages/jest-resolve-dependencies/package.json index 1cbb49f93747..694707bec6be 100644 --- a/packages/jest-resolve-dependencies/package.json +++ b/packages/jest-resolve-dependencies/package.json @@ -1,6 +1,6 @@ { "name": "jest-resolve-dependencies", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-resolve/package.json b/packages/jest-resolve/package.json index 992a6605049b..cd66b4e8f988 100644 --- a/packages/jest-resolve/package.json +++ b/packages/jest-resolve/package.json @@ -1,6 +1,6 @@ { "name": "jest-resolve", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index 17fb87a44e60..99dde0f6c23d 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -1,6 +1,6 @@ { "name": "jest-runner", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-runtime/package.json b/packages/jest-runtime/package.json index d182a9aa405b..8d9fad927ab2 100644 --- a/packages/jest-runtime/package.json +++ b/packages/jest-runtime/package.json @@ -1,6 +1,6 @@ { "name": "jest-runtime", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-snapshot/package.json b/packages/jest-snapshot/package.json index f9fa7fef9102..32a1402a7552 100644 --- a/packages/jest-snapshot/package.json +++ b/packages/jest-snapshot/package.json @@ -1,6 +1,6 @@ { "name": "jest-snapshot", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-test-result/package.json b/packages/jest-test-result/package.json index 2077d5268c75..b462a1548ce5 100644 --- a/packages/jest-test-result/package.json +++ b/packages/jest-test-result/package.json @@ -1,6 +1,6 @@ { "name": "@jest/test-result", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-test-sequencer/package.json b/packages/jest-test-sequencer/package.json index 92e321fcc4d6..7fd6f193945d 100644 --- a/packages/jest-test-sequencer/package.json +++ b/packages/jest-test-sequencer/package.json @@ -1,6 +1,6 @@ { "name": "@jest/test-sequencer", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-transform/package.json b/packages/jest-transform/package.json index 542de763867f..27484d70e262 100644 --- a/packages/jest-transform/package.json +++ b/packages/jest-transform/package.json @@ -1,6 +1,6 @@ { "name": "@jest/transform", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-watcher/package.json b/packages/jest-watcher/package.json index d7084927b609..a74eaafc50b6 100644 --- a/packages/jest-watcher/package.json +++ b/packages/jest-watcher/package.json @@ -1,7 +1,7 @@ { "name": "jest-watcher", "description": "Delightful JavaScript Testing.", - "version": "29.6.3", + "version": "29.6.4", "main": "./build/index.js", "types": "./build/index.d.ts", "exports": { diff --git a/packages/jest-worker/package.json b/packages/jest-worker/package.json index 447c0220bd05..2321b78a6bc2 100644 --- a/packages/jest-worker/package.json +++ b/packages/jest-worker/package.json @@ -1,6 +1,6 @@ { "name": "jest-worker", - "version": "29.6.3", + "version": "29.6.4", "repository": { "type": "git", "url": "https://github.com/jestjs/jest.git", diff --git a/packages/jest-worker/src/workers/__tests__/threadChild.test.ts b/packages/jest-worker/src/workers/__tests__/threadChild.test.ts index 649317919f6f..b7637963969f 100644 --- a/packages/jest-worker/src/workers/__tests__/threadChild.test.ts +++ b/packages/jest-worker/src/workers/__tests__/threadChild.test.ts @@ -365,3 +365,24 @@ it('throws if child is not forked', () => { messagePort.emit('message', [CHILD_MESSAGE_CALL, true, 'fooThrows', []]); }).toThrow('_worker_threads.parentPort.postMessage is not a function'); }); + +it('handle error if `postMessage` throws an error', () => { + messagePort.emit('message', [ + CHILD_MESSAGE_INITIALIZE, + true, + './my-fancy-worker', + ]); + + jest.mocked(messagePort.postMessage).mockImplementationOnce(() => { + throw mockError; + }); + + messagePort.emit('message', [CHILD_MESSAGE_CALL, true, 'fooWorks', []]); + expect(jest.mocked(messagePort.postMessage).mock.calls[1][0]).toEqual([ + PARENT_MESSAGE_CLIENT_ERROR, + 'TypeError', + 'Boo', + mockError.stack, + {}, + ]); +}); diff --git a/packages/jest-worker/src/workers/threadChild.ts b/packages/jest-worker/src/workers/threadChild.ts index 2380e1afd23c..efd31d04ed37 100644 --- a/packages/jest-worker/src/workers/threadChild.ts +++ b/packages/jest-worker/src/workers/threadChild.ts @@ -112,7 +112,14 @@ function reportSuccess(result: unknown) { throw new Error('Child can only be used on a forked process'); } - parentPort!.postMessage([PARENT_MESSAGE_OK, result]); + try { + parentPort!.postMessage([PARENT_MESSAGE_OK, result]); + } catch (err: any) { + // Handling it here to avoid unhandled `DataCloneError` rejection + // which is hard to distinguish on the parent side + // (such error doesn't have any message or stack trace) + reportClientError(err); + } } function reportClientError(error: Error) { diff --git a/packages/jest/package.json b/packages/jest/package.json index 6d9efe8943ca..86da00852d86 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -1,7 +1,7 @@ { "name": "jest", "description": "Delightful JavaScript Testing.", - "version": "29.6.3", + "version": "29.6.4", "main": "./build/index.js", "types": "./build/index.d.ts", "exports": { diff --git a/packages/test-globals/package.json b/packages/test-globals/package.json index 4361d5984ebd..2e92280850ae 100644 --- a/packages/test-globals/package.json +++ b/packages/test-globals/package.json @@ -1,6 +1,6 @@ { "name": "@jest/test-globals", - "version": "29.6.3", + "version": "29.6.4", "private": true, "main": "./build/index.js", "types": "./build/index.d.ts", diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 955209adab6e..63be4ec2907e 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@jest/test-utils", - "version": "29.6.3", + "version": "29.6.4", "private": true, "main": "./build/index.js", "types": "./build/index.d.ts", diff --git a/website/versioned_docs/version-29.4/Configuration.md b/website/versioned_docs/version-29.4/Configuration.md index ed92e8e2bef9..c4676dd7bfe8 100644 --- a/website/versioned_docs/version-29.4/Configuration.md +++ b/website/versioned_docs/version-29.4/Configuration.md @@ -1330,7 +1330,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments: ```js title="custom-reporter.js" class CustomReporter { @@ -1359,6 +1359,12 @@ class CustomReporter { module.exports = CustomReporter; ``` +:::note + +For the full list of hooks and argument types see the `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts). + +::: + ### `resetMocks` \[boolean] Default: `false` diff --git a/website/versioned_docs/version-29.4/ManualMocks.md b/website/versioned_docs/version-29.4/ManualMocks.md index d166114387eb..7d7e9ab8f1d1 100644 --- a/website/versioned_docs/version-29.4/ManualMocks.md +++ b/website/versioned_docs/version-29.4/ManualMocks.md @@ -29,7 +29,7 @@ Scoped modules (also known as [scoped packages](https://docs.npmjs.com/cli/v6/us :::caution -If we want to mock Node's build-in modules (e.g.: `fs` or `path`), then explicitly calling e.g. `jest.mock('path')` is **required**, because build-in modules are not mocked by default. +If we want to mock Node's built-in modules (e.g.: `fs` or `path`), then explicitly calling e.g. `jest.mock('path')` is **required**, because built-in modules are not mocked by default. ::: @@ -110,7 +110,7 @@ fs.readdirSync = readdirSync; module.exports = fs; ``` -Now we write our test. In this case `jest.mock('fs')` must be called explicitly, because `fs` is Node’s build-in module: +Now we write our test. In this case `jest.mock('fs')` must be called explicitly, because `fs` is Node’s built-in module: ```javascript title="__tests__/FileSummarizer-test.js" 'use strict'; diff --git a/website/versioned_docs/version-29.5/Configuration.md b/website/versioned_docs/version-29.5/Configuration.md index 0604ca6f965a..1c638f727250 100644 --- a/website/versioned_docs/version-29.5/Configuration.md +++ b/website/versioned_docs/version-29.5/Configuration.md @@ -1365,7 +1365,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments: ```js title="custom-reporter.js" class CustomReporter { @@ -1394,6 +1394,12 @@ class CustomReporter { module.exports = CustomReporter; ``` +:::note + +For the full list of hooks and argument types see the `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts). + +::: + ### `resetMocks` \[boolean] Default: `false` diff --git a/website/versioned_docs/version-29.5/ManualMocks.md b/website/versioned_docs/version-29.5/ManualMocks.md index d166114387eb..7d7e9ab8f1d1 100644 --- a/website/versioned_docs/version-29.5/ManualMocks.md +++ b/website/versioned_docs/version-29.5/ManualMocks.md @@ -29,7 +29,7 @@ Scoped modules (also known as [scoped packages](https://docs.npmjs.com/cli/v6/us :::caution -If we want to mock Node's build-in modules (e.g.: `fs` or `path`), then explicitly calling e.g. `jest.mock('path')` is **required**, because build-in modules are not mocked by default. +If we want to mock Node's built-in modules (e.g.: `fs` or `path`), then explicitly calling e.g. `jest.mock('path')` is **required**, because built-in modules are not mocked by default. ::: @@ -110,7 +110,7 @@ fs.readdirSync = readdirSync; module.exports = fs; ``` -Now we write our test. In this case `jest.mock('fs')` must be called explicitly, because `fs` is Node’s build-in module: +Now we write our test. In this case `jest.mock('fs')` must be called explicitly, because `fs` is Node’s built-in module: ```javascript title="__tests__/FileSummarizer-test.js" 'use strict'; diff --git a/website/versioned_docs/version-29.6/Configuration.md b/website/versioned_docs/version-29.6/Configuration.md index 4e23e314b103..1a50070df269 100644 --- a/website/versioned_docs/version-29.6/Configuration.md +++ b/website/versioned_docs/version-29.6/Configuration.md @@ -1401,7 +1401,7 @@ Hungry for reporters? Take a look at long list of [awesome reporters](https://gi ::: -Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments and implements at least `onRunComplete()` method (for the full list of methods and argument types see `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts)): +Custom reporter module must export a class that takes [`globalConfig`](https://github.com/jestjs/jest/blob/v29.2.1/packages/jest-types/src/Config.ts#L358-L422), `reporterOptions` and `reporterContext` as constructor arguments: ```js title="custom-reporter.js" class CustomReporter { @@ -1430,6 +1430,12 @@ class CustomReporter { module.exports = CustomReporter; ``` +:::note + +For the full list of hooks and argument types see the `Reporter` interface in [packages/jest-reporters/src/types.ts](https://github.com/jestjs/jest/blob/main/packages/jest-reporters/src/types.ts). + +::: + ### `resetMocks` \[boolean] Default: `false` diff --git a/website/versioned_docs/version-29.6/ManualMocks.md b/website/versioned_docs/version-29.6/ManualMocks.md index d166114387eb..7d7e9ab8f1d1 100644 --- a/website/versioned_docs/version-29.6/ManualMocks.md +++ b/website/versioned_docs/version-29.6/ManualMocks.md @@ -29,7 +29,7 @@ Scoped modules (also known as [scoped packages](https://docs.npmjs.com/cli/v6/us :::caution -If we want to mock Node's build-in modules (e.g.: `fs` or `path`), then explicitly calling e.g. `jest.mock('path')` is **required**, because build-in modules are not mocked by default. +If we want to mock Node's built-in modules (e.g.: `fs` or `path`), then explicitly calling e.g. `jest.mock('path')` is **required**, because built-in modules are not mocked by default. ::: @@ -110,7 +110,7 @@ fs.readdirSync = readdirSync; module.exports = fs; ``` -Now we write our test. In this case `jest.mock('fs')` must be called explicitly, because `fs` is Node’s build-in module: +Now we write our test. In this case `jest.mock('fs')` must be called explicitly, because `fs` is Node’s built-in module: ```javascript title="__tests__/FileSummarizer-test.js" 'use strict';