diff --git a/CHANGELOG.md b/CHANGELOG.md index 324d27b4caa8..cd5316399f61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,25 @@ ### Performance +## 26.6.0 + +### Features + +- `[jest-cli, jest-config]` Add support for the `jest.config.ts` configuration file ([#10564](https://github.com/facebook/jest/pull/10564)) + +### Fixes + +- `[jest-config]` Simplify transform RegExp ([#10207](https://github.com/facebook/jest/pull/10207)) +- `[jest-fake-timers]` Lazily instantiate mock timers ([#10551](https://github.com/facebook/jest/pull/10551)) +- `[jest-runtime]` `require.main` is no longer `undefined` when using `jest.resetModules` ([#10626](https://github.com/facebook/jest/pull/10626)) +- `[@jest/types]` Add missing values for `timers` ([#10632](https://github.com/facebook/jest/pull/10632)) + +### Chore & Maintenance + +- `[docs]` Add step for fetching `backers.json` file in website setup docs ([#10631](https://github.com/facebook/jest/pull/10631)) +- `[docs]` Add page detailing environment variables set by Jest ([#10630](https://github.com/facebook/jest/pull/10630)) +- `[jest-circus]` Refactor `callAsyncCircusFn` parameters ([#10629](https://github.com/facebook/jest/pull/10629)) + ## 26.5.3 ### Features diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 971973cefc70..ae76536aa041 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -143,6 +143,7 @@ If you are making changes to the website or documentation, test the website fold ```sh-session $ cd website # Only needed if you are not already in the website directory $ yarn + $ node fetchSupporters.js $ yarn start ``` 1. You can run a development server to check if the changes you made are being displayed accurately by running `yarn start` in the website directory. diff --git a/README.md b/README.md index ca5936aeb337..3b713b347e0b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ -

+

npm version - Follow on Twitter + + Jest is released under the MIT license. + + Follow on Twitter

diff --git a/docs/Configuration.md b/docs/Configuration.md index 9e485fcafc34..a925caa51bf4 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -3,7 +3,7 @@ id: configuration title: Configuring Jest --- -Jest's configuration can be defined in the `package.json` file of your project, or through a `jest.config.js` file or through the `--config ` option. If you'd like to use your `package.json` to store Jest's config, the `"jest"` key should be used on the top level so Jest will know how to find your settings: +Jest's configuration can be defined in the `package.json` file of your project, or through a `jest.config.js`, or `jest.config.ts` file or through the `--config ` option. If you'd like to use your `package.json` to store Jest's config, the `"jest"` key should be used on the top level so Jest will know how to find your settings: ```json { @@ -18,12 +18,12 @@ Or through JavaScript: ```js // jest.config.js -//Sync object +// Sync object module.exports = { verbose: true, }; -//Or async function +// Or async function module.exports = async () => { return { verbose: true, @@ -31,6 +31,26 @@ module.exports = async () => { }; ``` +Or through TypeScript (if `ts-node` is installed): + +```ts +// jest.config.ts +import type {Config} from '@jest/types'; + +// Sync object +const config: Config.InitialOptions = { + verbose: true, +}; +export default config; + +// Or async function +export default async (): Promise => { + return { + verbose: true, + }; +}; +``` + Please keep in mind that the resulting configuration must be JSON-serializable. When using the `--config` option, the JSON file must not contain a "jest" key: @@ -1203,7 +1223,7 @@ If the value is `modern`, [`@sinonjs/fake-timers`](https://github.com/sinonjs/fa ### `transform` [object\] -Default: `{"^.+\\.[jt]sx?$": "babel-jest"}` +Default: `{"\\.[jt]sx?$": "babel-jest"}` A map from regular expressions to paths to transformers. A transformer is a module that provides a synchronous function for transforming source files. For example, if you wanted to be able to use a new language feature in your modules or tests that aren't yet supported by node, you might plug in one of many compilers that compile a future version of JavaScript to a current one. Example: see the [examples/typescript](https://github.com/facebook/jest/blob/master/examples/typescript/package.json#L16) example or the [webpack tutorial](Webpack.md). @@ -1218,7 +1238,7 @@ You can pass configuration to a transformer like `{filePattern: ['path-to-transf _Note: a transformer is only run once per file unless the file has changed. During the development of a transformer it can be useful to run Jest with `--no-cache` to frequently [delete Jest's cache](Troubleshooting.md#caching-issues)._ -_Note: when adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"^.+\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/facebook/jest/tree/master/packages/babel-jest#setup)_ +_Note: when adding additional code transformers, this will overwrite the default config and `babel-jest` is no longer automatically loaded. If you want to use it to compile JavaScript or Typescript, it has to be explicitly defined by adding `{"\\.[jt]sx?$": "babel-jest"}` to the transform property. See [babel-jest plugin](https://github.com/facebook/jest/tree/master/packages/babel-jest#setup)_ ### `transformIgnorePatterns` [array\] diff --git a/docs/ECMAScriptModules.md b/docs/ECMAScriptModules.md index 40320348203a..7c0cc2792b07 100644 --- a/docs/ECMAScriptModules.md +++ b/docs/ECMAScriptModules.md @@ -12,5 +12,5 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc. +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details diff --git a/docs/EnvironmentVariables.md b/docs/EnvironmentVariables.md new file mode 100644 index 000000000000..fb50c3e72d08 --- /dev/null +++ b/docs/EnvironmentVariables.md @@ -0,0 +1,14 @@ +--- +id: environment-variables +title: Environment Variables +--- + +Jest sets the following environment variables: + +### `NODE_ENV` + +Set to `'test'` if it's not already set to something else. + +### `JEST_WORKER_ID` + +Each worker process is assigned a unique id (index-based that starts with `1`). This is set to `1` for all tests when [`runInBand`](CLI.md#--runinband) is set to true. diff --git a/docs/Webpack.md b/docs/Webpack.md index ea6d9391628e..e629d32a52b6 100644 --- a/docs/Webpack.md +++ b/docs/Webpack.md @@ -125,8 +125,8 @@ _Note: if you are using babel-jest with additional code preprocessors, you have ```json "transform": { - "^.+\\.js$": "babel-jest", - "^.+\\.css$": "custom-transformer", + "\\.js$": "babel-jest", + "\\.css$": "custom-transformer", ... } ``` diff --git a/e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap b/e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap index 0057efd49acc..7ecaecdb7868 100644 --- a/e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap +++ b/e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap @@ -14,7 +14,4 @@ PASS __tests__/console.test.js 13 | }); 14 | }); 15 | - - at BufferedConsole.log (../../packages/jest-console/build/BufferedConsole.js:197:10) - at log (__tests__/console.test.js:12:13) `; diff --git a/e2e/__tests__/__snapshots__/jest.config.ts.test.ts.snap b/e2e/__tests__/__snapshots__/jest.config.ts.test.ts.snap new file mode 100644 index 000000000000..231d926a36de --- /dev/null +++ b/e2e/__tests__/__snapshots__/jest.config.ts.test.ts.snap @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`traverses directory tree up until it finds jest.config 1`] = ` + console.log +<>/jest.config.ts/some/nested/directory + + at Object.log (__tests__/a-giraffe.js:3:27) + +`; + +exports[`traverses directory tree up until it finds jest.config 2`] = ` +PASS ../../../__tests__/a-giraffe.js + ✓ giraffe + ✓ abc +`; + +exports[`traverses directory tree up until it finds jest.config 3`] = ` +Test Suites: 1 passed, 1 total +Tests: 2 passed, 2 total +Snapshots: 0 total +Time: <> +Ran all test suites. +`; + +exports[`works with jest.config.ts 1`] = ` +PASS __tests__/a-giraffe.js + ✓ giraffe +`; + +exports[`works with jest.config.ts 2`] = ` +Test Suites: 1 passed, 1 total +Tests: 1 passed, 1 total +Snapshots: 0 total +Time: <> +Ran all test suites. +`; diff --git a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap index 61f2d402cf2d..7fc1128c1c9e 100644 --- a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap +++ b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap @@ -67,7 +67,7 @@ exports[`--showConfig outputs config info and exits 1`] = ` "timers": "real", "transform": [ [ - "^.+\\\\.[jt]sx?$", + "\\\\.[jt]sx?$", "<>/babel-jest/build/index.js", {} ] diff --git a/e2e/__tests__/consoleAfterTeardown.test.ts b/e2e/__tests__/consoleAfterTeardown.test.ts index 543da32f4d0f..fb1b6fa68b92 100644 --- a/e2e/__tests__/consoleAfterTeardown.test.ts +++ b/e2e/__tests__/consoleAfterTeardown.test.ts @@ -14,5 +14,8 @@ test('console printing', () => { const {rest} = extractSummary(stderr); expect(exitCode).toBe(0); - expect(wrap(rest)).toMatchSnapshot(); + + const withoutTrace = rest.split('\n').slice(0, -3).join('\n'); + + expect(wrap(withoutTrace)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/jest.config.ts.test.ts b/e2e/__tests__/jest.config.ts.test.ts new file mode 100644 index 000000000000..9b3edcef87ff --- /dev/null +++ b/e2e/__tests__/jest.config.ts.test.ts @@ -0,0 +1,83 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import * as path from 'path'; +import {wrap} from 'jest-snapshot-serializer-raw'; +import runJest from '../runJest'; +import {cleanup, extractSummary, writeFiles} from '../Utils'; + +const DIR = path.resolve(__dirname, '../jest.config.ts'); + +beforeEach(() => cleanup(DIR)); +afterAll(() => cleanup(DIR)); + +test('works with jest.config.ts', () => { + writeFiles(DIR, { + '__tests__/a-giraffe.js': `test('giraffe', () => expect(1).toBe(1));`, + 'jest.config.ts': `export default {testEnvironment: 'jest-environment-node', testRegex: '.*-giraffe.js'};`, + 'package.json': '{}', + }); + + const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false']); + const {rest, summary} = extractSummary(stderr); + expect(exitCode).toBe(0); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); +}); + +test('traverses directory tree up until it finds jest.config', () => { + writeFiles(DIR, { + '__tests__/a-giraffe.js': ` + const slash = require('slash'); + test('giraffe', () => expect(1).toBe(1)); + test('abc', () => console.log(slash(process.cwd()))); + `, + 'jest.config.ts': `export default {testEnvironment: 'jest-environment-node', testRegex: '.*-giraffe.js'};`, + 'package.json': '{}', + 'some/nested/directory/file.js': '// nothing special', + }); + + const {stderr, exitCode, stdout} = runJest( + path.join(DIR, 'some', 'nested', 'directory'), + ['-w=1', '--ci=false'], + {skipPkgJsonCheck: true}, + ); + + // Snapshot the console.loged `process.cwd()` and make sure it stays the same + expect( + wrap(stdout.replace(/^\W+(.*)e2e/gm, '<>')), + ).toMatchSnapshot(); + + const {rest, summary} = extractSummary(stderr); + expect(exitCode).toBe(0); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); +}); + +test('it does type check the config', () => { + writeFiles(DIR, { + '__tests__/a-giraffe.js': `test('giraffe', () => expect(1).toBe(1));`, + 'jest.config.ts': `export default { testTimeout: "10000" }`, + 'package.json': '{}', + }); + + const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false']); + expect(stderr).toMatch('must be of type'); + expect(exitCode).toBe(1); +}); + +test('invalid JS in jest.config.ts', () => { + writeFiles(DIR, { + '__tests__/a-giraffe.js': `test('giraffe', () => expect(1).toBe(1));`, + 'jest.config.ts': `export default i'll break this file yo`, + 'package.json': '{}', + }); + + const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false']); + expect(stderr).toMatch('TSError: ⨯ Unable to compile TypeScript:'); + expect(exitCode).toBe(1); +}); diff --git a/e2e/__tests__/requireMainResetModules.test.ts b/e2e/__tests__/requireMainResetModules.test.ts new file mode 100644 index 000000000000..f292d991bc4d --- /dev/null +++ b/e2e/__tests__/requireMainResetModules.test.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import runJest from '../runJest'; + +test("`require.main` on using `--resetModules='true'` should not be undefined", () => { + const {exitCode} = runJest('require-main-reset-modules', [ + `--resetModules='true'`, + 'resetModulesFlag', + ]); + expect(exitCode).toBe(0); +}); + +test('`require.main` on using `jest.resetModules()` should not be undefined', () => { + const {exitCode} = runJest('require-main-reset-modules', [ + 'resetModulesCall', + ]); + expect(exitCode).toBe(0); +}); diff --git a/e2e/coverage-remapping/package.json b/e2e/coverage-remapping/package.json index 774dda6861dd..ff2715e71f98 100644 --- a/e2e/coverage-remapping/package.json +++ b/e2e/coverage-remapping/package.json @@ -2,7 +2,7 @@ "jest": { "rootDir": "./", "transform": { - "^.+\\.(ts|js)$": "/typescriptPreprocessor.js" + "\\.(ts|js)$": "/typescriptPreprocessor.js" }, "testEnvironment": "node" }, diff --git a/e2e/coverage-transform-instrumented/package.json b/e2e/coverage-transform-instrumented/package.json index 5676ccada0fc..db634e8daac3 100644 --- a/e2e/coverage-transform-instrumented/package.json +++ b/e2e/coverage-transform-instrumented/package.json @@ -2,7 +2,7 @@ "jest": { "rootDir": "./", "transform": { - "^.+\\.(js)$": "/preprocessor.js" + "\\.(js)$": "/preprocessor.js" }, "testRegex": "/__tests__/.*\\.(js)$", "testEnvironment": "node", diff --git a/e2e/global-setup-custom-transform/package.json b/e2e/global-setup-custom-transform/package.json index 508172a45c33..c6a790b34eff 100644 --- a/e2e/global-setup-custom-transform/package.json +++ b/e2e/global-setup-custom-transform/package.json @@ -3,7 +3,7 @@ "testEnvironment": "node", "globalSetup": "/setup.js", "transform": { - "^.+\\.js$": "/transformer.js" + "\\.js$": "/transformer.js" } } } diff --git a/e2e/node-path/package.json b/e2e/node-path/package.json index ab33604cd518..fa03d1c35d08 100644 --- a/e2e/node-path/package.json +++ b/e2e/node-path/package.json @@ -2,7 +2,7 @@ "jest": { "testEnvironment": "node", "transform": { - "^.+\\.jsx?$": "../../packages/babel-jest" + "\\.jsx?$": "../../packages/babel-jest" } } } diff --git a/e2e/package.json b/e2e/package.json index 791c8012767a..6f5befae69a6 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -1,7 +1,7 @@ { "jest": { "transform": { - "^.+\\.js$": "/../packages/babel-jest" + "\\.js$": "/../packages/babel-jest" }, "testEnvironment": "node", "testPathIgnorePatterns": [ diff --git a/e2e/require-main-reset-modules/__tests__/resetModulesCallDirectly.test.js b/e2e/require-main-reset-modules/__tests__/resetModulesCallDirectly.test.js new file mode 100644 index 000000000000..8108218178c9 --- /dev/null +++ b/e2e/require-main-reset-modules/__tests__/resetModulesCallDirectly.test.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +beforeEach(() => { + jest.resetModules(); +}); + +afterEach(() => { + jest.resetModules(); +}); + +test('require.main is set on requiring directly', () => { + const {getMain} = require('../direct.js'); + expect(getMain()).toBeTruthy(); +}); + +test('require from main works on requiring directly', () => { + const {requireFromMain} = require('../direct.js'); + expect(requireFromMain('../package.json')).toBeTruthy(); +}); diff --git a/e2e/require-main-reset-modules/__tests__/resetModulesCallIndirectly.test.js b/e2e/require-main-reset-modules/__tests__/resetModulesCallIndirectly.test.js new file mode 100644 index 000000000000..14c9027c81a9 --- /dev/null +++ b/e2e/require-main-reset-modules/__tests__/resetModulesCallIndirectly.test.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +beforeEach(() => { + jest.resetModules(); +}); + +afterEach(() => { + jest.resetModules(); +}); + +test('require.main is set on requiring indirectly', () => { + const {getMain} = require('../indirect.js'); + expect(getMain()).toBeTruthy(); +}); + +test('require from main works on requiring indirectly', () => { + const {requireFromMain} = require('../indirect.js'); + expect(requireFromMain('../package.json')).toBeTruthy(); +}); diff --git a/e2e/require-main-reset-modules/__tests__/resetModulesFlagDirectly.test.js b/e2e/require-main-reset-modules/__tests__/resetModulesFlagDirectly.test.js new file mode 100644 index 000000000000..68ba72f8b00c --- /dev/null +++ b/e2e/require-main-reset-modules/__tests__/resetModulesFlagDirectly.test.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +test('require.main is set', () => { + const {getMain} = require('../direct.js'); + expect(getMain()).toBeTruthy(); +}); + +test('require from main works', () => { + const {requireFromMain} = require('../direct.js'); + expect(requireFromMain('../package.json')).toBeTruthy(); +}); diff --git a/e2e/require-main-reset-modules/__tests__/resetModulesFlagIndirectly.test.js b/e2e/require-main-reset-modules/__tests__/resetModulesFlagIndirectly.test.js new file mode 100644 index 000000000000..980c9158af73 --- /dev/null +++ b/e2e/require-main-reset-modules/__tests__/resetModulesFlagIndirectly.test.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +test('require.main is set', () => { + const {getMain} = require('../indirect.js'); + expect(getMain()).toBeTruthy(); +}); + +test('require from main works', () => { + const {requireFromMain} = require('../indirect.js'); + expect(requireFromMain('../package.json')).toBeTruthy(); +}); diff --git a/e2e/require-main-reset-modules/direct.js b/e2e/require-main-reset-modules/direct.js new file mode 100644 index 000000000000..384d02c8d4b7 --- /dev/null +++ b/e2e/require-main-reset-modules/direct.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +Object.assign(exports, {getMain, requireFromMain}); + +function getMain() { + return require.main; +} + +function requireFromMain(pkg) { + return getMain().require(pkg); +} diff --git a/e2e/require-main-reset-modules/indirect.js b/e2e/require-main-reset-modules/indirect.js new file mode 100644 index 000000000000..cd8a5c98d41a --- /dev/null +++ b/e2e/require-main-reset-modules/indirect.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +const {getMain, requireFromMain} = require('./direct'); +Object.assign(exports, {getMain, requireFromMain}); diff --git a/e2e/require-main-reset-modules/package.json b/e2e/require-main-reset-modules/package.json new file mode 100644 index 000000000000..148788b25446 --- /dev/null +++ b/e2e/require-main-reset-modules/package.json @@ -0,0 +1,5 @@ +{ + "jest": { + "testEnvironment": "node" + } +} diff --git a/e2e/snapshot-serializers/package.json b/e2e/snapshot-serializers/package.json index 658160fc0f8e..2eab6d3f2150 100644 --- a/e2e/snapshot-serializers/package.json +++ b/e2e/snapshot-serializers/package.json @@ -2,7 +2,7 @@ "jest": { "testEnvironment": "node", "transform": { - "^.+\\.js$": "/transformer.js" + "\\.js$": "/transformer.js" }, "snapshotSerializers": [ "./plugins/foo", diff --git a/e2e/stack-trace-source-maps-with-coverage/package.json b/e2e/stack-trace-source-maps-with-coverage/package.json index f8fbad2d8bca..56d2defe8c95 100644 --- a/e2e/stack-trace-source-maps-with-coverage/package.json +++ b/e2e/stack-trace-source-maps-with-coverage/package.json @@ -2,7 +2,7 @@ "jest": { "rootDir": "./", "transform": { - "^.+\\.(ts)$": "/preprocessor.js" + "\\.(ts)$": "/preprocessor.js" }, "testEnvironment": "node", "testRegex": "fails" diff --git a/e2e/stack-trace-source-maps/package.json b/e2e/stack-trace-source-maps/package.json index f8fbad2d8bca..56d2defe8c95 100644 --- a/e2e/stack-trace-source-maps/package.json +++ b/e2e/stack-trace-source-maps/package.json @@ -2,7 +2,7 @@ "jest": { "rootDir": "./", "transform": { - "^.+\\.(ts)$": "/preprocessor.js" + "\\.(ts)$": "/preprocessor.js" }, "testEnvironment": "node", "testRegex": "fails" diff --git a/e2e/transform-linked-modules/package.json b/e2e/transform-linked-modules/package.json index 0887a1756750..76fce8cdf931 100644 --- a/e2e/transform-linked-modules/package.json +++ b/e2e/transform-linked-modules/package.json @@ -7,7 +7,7 @@ "/ignored/" ], "transform": { - "^.+\\.js$": "/preprocessor.js" + "\\.js$": "/preprocessor.js" } } } diff --git a/e2e/transform/cache/package.json b/e2e/transform/cache/package.json index d75bca46c3ba..3bd182db1258 100644 --- a/e2e/transform/cache/package.json +++ b/e2e/transform/cache/package.json @@ -4,7 +4,7 @@ "jest": { "testEnvironment": "node", "transform": { - "^.+\\.js$": "/transformer.js" + "\\.js$": "/transformer.js" } } } diff --git a/e2e/transform/custom-instrumenting-preprocessor/package.json b/e2e/transform/custom-instrumenting-preprocessor/package.json index 088eb25348a4..f1e6d9d26756 100644 --- a/e2e/transform/custom-instrumenting-preprocessor/package.json +++ b/e2e/transform/custom-instrumenting-preprocessor/package.json @@ -1,7 +1,7 @@ { "jest": { "transform": { - "^.+\\.js$": "/preprocessor.js" + "\\.js$": "/preprocessor.js" }, "testEnvironment": "node" } diff --git a/e2e/transform/ecmascript-modules-support/package.json b/e2e/transform/ecmascript-modules-support/package.json index d37c7ca66af6..35192357168b 100644 --- a/e2e/transform/ecmascript-modules-support/package.json +++ b/e2e/transform/ecmascript-modules-support/package.json @@ -12,7 +12,7 @@ "**/__tests__/**/*.mjs" ], "transform": { - "^.+\\.mjs?$": "../../../packages/babel-jest" + "\\.mjs?$": "../../../packages/babel-jest" } } } diff --git a/e2e/transform/multiple-transformers/package.json b/e2e/transform/multiple-transformers/package.json index 393763823ac8..47cbbff146f2 100644 --- a/e2e/transform/multiple-transformers/package.json +++ b/e2e/transform/multiple-transformers/package.json @@ -1,9 +1,9 @@ { "jest": { "transform": { - "^.+\\.css$": "/cssPreprocessor.js", - "^.+\\.js$": "/jsPreprocessor.js", - "^.+\\.svg$": "/filePreprocessor.js" + "\\.css$": "/cssPreprocessor.js", + "\\.js$": "/jsPreprocessor.js", + "\\.svg$": "/filePreprocessor.js" }, "testEnvironment": "node" }, diff --git a/e2e/typescript-coverage/package.json b/e2e/typescript-coverage/package.json index ffe9414a2849..24255a467dd7 100644 --- a/e2e/typescript-coverage/package.json +++ b/e2e/typescript-coverage/package.json @@ -2,7 +2,7 @@ "jest": { "rootDir": "./", "transform": { - "^.+\\.(ts|js)$": "/typescriptPreprocessor.js" + "\\.(ts|js)$": "/typescriptPreprocessor.js" }, "testEnvironment": "node" }, diff --git a/e2e/v8-coverage/no-sourcemap/package.json b/e2e/v8-coverage/no-sourcemap/package.json index 033719f58b9b..e63e40a94614 100644 --- a/e2e/v8-coverage/no-sourcemap/package.json +++ b/e2e/v8-coverage/no-sourcemap/package.json @@ -4,8 +4,8 @@ "jest": { "testEnvironment": "node", "transform": { - "^.+\\.[jt]sx?$": "babel-jest", - "^.+\\.css$": "/cssTransform.js" + "\\.[jt]sx?$": "babel-jest", + "\\.css$": "/cssTransform.js" } } } diff --git a/examples/angular/jest.config.js b/examples/angular/jest.config.js index 4329aeac9dad..e6cbd08cca2f 100644 --- a/examples/angular/jest.config.js +++ b/examples/angular/jest.config.js @@ -2,9 +2,6 @@ module.exports = { moduleFileExtensions: ['ts', 'html', 'js', 'json'], setupFilesAfterEnv: ['/setupJest.js'], transform: { - '^.+\\.[t|j]s$': [ - 'babel-jest', - {configFile: require.resolve('./.babelrc')}, - ], + '\\.[tj]s$': ['babel-jest', {configFile: require.resolve('./.babelrc')}], }, }; diff --git a/examples/react-native/jest.config.js b/examples/react-native/jest.config.js index ec9160a9797c..802106b0009d 100644 --- a/examples/react-native/jest.config.js +++ b/examples/react-native/jest.config.js @@ -1,6 +1,6 @@ module.exports = { preset: 'react-native', transform: { - '^.+\\.(js|ts|tsx)$': require.resolve('react-native/jest/preprocessor.js'), + '\\.(js|ts|tsx)$': require.resolve('react-native/jest/preprocessor.js'), }, }; diff --git a/jest.config.js b/jest.config.js index 9f45edb32b42..dcad9d20336a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -63,7 +63,7 @@ module.exports = { '/e2e/__tests__/iterator-to-null-test.ts', ], transform: { - '^.+\\.[jt]sx?$': '/packages/babel-jest', + '\\.[jt]sx?$': '/packages/babel-jest', }, watchPathIgnorePatterns: ['coverage'], watchPlugins: [ diff --git a/lerna.json b/lerna.json index b1b8e38d5a4a..c1b52df5fd30 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "26.5.3", + "version": "26.6.0", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/package.json b/package.json index eec05964f672..899223832694 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "strip-ansi": "^6.0.0", "tempy": "^0.6.0", "throat": "^5.0.0", + "ts-node": "^9.0.0", "type-fest": "^0.16.0", "typescript": "^4.0.2", "which": "^2.0.1" diff --git a/packages/babel-jest/README.md b/packages/babel-jest/README.md index 237e5b6d53b7..95050196b2a0 100644 --- a/packages/babel-jest/README.md +++ b/packages/babel-jest/README.md @@ -20,6 +20,6 @@ To explicitly define `babel-jest` as a transformer for your JavaScript code, map ```json "transform": { - "^.+\\.[t|j]sx?$": "babel-jest" + "\\.[jt]sx?$": "babel-jest" }, ``` diff --git a/packages/babel-jest/package.json b/packages/babel-jest/package.json index 5cd5a988ab94..f6963a6f5313 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": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -11,8 +11,8 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/transform": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/transform": "^26.6.0", + "@jest/types": "^26.6.0", "@types/babel__core": "^7.1.7", "babel-plugin-istanbul": "^6.0.0", "babel-preset-jest": "^26.5.0", diff --git a/packages/expect/package.json b/packages/expect/package.json index 9e5daf00e100..af15a9caa6cd 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -1,6 +1,6 @@ { "name": "expect", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,11 +10,11 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "ansi-styles": "^4.0.0", "jest-get-type": "^26.3.0", - "jest-matcher-utils": "^26.5.2", - "jest-message-util": "^26.5.2", + "jest-matcher-utils": "^26.6.0", + "jest-message-util": "^26.6.0", "jest-regex-util": "^26.0.0" }, "devDependencies": { diff --git a/packages/jest-changed-files/package.json b/packages/jest-changed-files/package.json index f3f45e4b1980..86f72a93ef55 100644 --- a/packages/jest-changed-files/package.json +++ b/packages/jest-changed-files/package.json @@ -1,6 +1,6 @@ { "name": "jest-changed-files", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,7 +10,7 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "execa": "^4.0.0", "throat": "^5.0.0" }, diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index ff77723e797a..7699bcdfe968 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -1,6 +1,6 @@ { "name": "jest-circus", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -11,24 +11,24 @@ "types": "build/index.d.ts", "dependencies": { "@babel/traverse": "^7.1.0", - "@jest/environment": "^26.5.2", - "@jest/test-result": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/environment": "^26.6.0", + "@jest/test-result": "^26.6.0", + "@jest/types": "^26.6.0", "@types/babel__traverse": "^7.0.4", "@types/node": "*", "chalk": "^4.0.0", "co": "^4.6.0", "dedent": "^0.7.0", - "expect": "^26.5.3", + "expect": "^26.6.0", "is-generator-fn": "^2.0.0", - "jest-each": "^26.5.2", - "jest-matcher-utils": "^26.5.2", - "jest-message-util": "^26.5.2", - "jest-runner": "^26.5.3", - "jest-runtime": "^26.5.3", - "jest-snapshot": "^26.5.3", - "jest-util": "^26.5.2", - "pretty-format": "^26.5.2", + "jest-each": "^26.6.0", + "jest-matcher-utils": "^26.6.0", + "jest-message-util": "^26.6.0", + "jest-runner": "^26.6.0", + "jest-runtime": "^26.6.0", + "jest-snapshot": "^26.6.0", + "jest-util": "^26.6.0", + "pretty-format": "^26.6.0", "stack-utils": "^2.0.2", "throat": "^5.0.0" }, diff --git a/packages/jest-circus/src/run.ts b/packages/jest-circus/src/run.ts index f9a9969c7b3b..c3509943c4c4 100644 --- a/packages/jest-circus/src/run.ts +++ b/packages/jest-circus/src/run.ts @@ -143,7 +143,7 @@ const _callCircusHook = async ({ const timeout = hook.timeout || getState().testTimeout; try { - await callAsyncCircusFn(hook.fn, testContext, hook.asyncError, { + await callAsyncCircusFn(hook, testContext, { isHook: true, timeout, }); @@ -166,7 +166,7 @@ const _callCircusTest = async ( } try { - await callAsyncCircusFn(test.fn, testContext, test.asyncError, { + await callAsyncCircusFn(test, testContext, { isHook: false, timeout, }); diff --git a/packages/jest-circus/src/utils.ts b/packages/jest-circus/src/utils.ts index b1e9f8aeb95d..333faf037691 100644 --- a/packages/jest-circus/src/utils.ts +++ b/packages/jest-circus/src/utils.ts @@ -7,7 +7,7 @@ import * as path from 'path'; import type {Circus} from '@jest/types'; -import {convertDescriptorToString, formatTime} from 'jest-util'; +import {ErrorWithStack, convertDescriptorToString, formatTime} from 'jest-util'; import isGeneratorFn from 'is-generator-fn'; import co from 'co'; import dedent = require('dedent'); @@ -43,7 +43,7 @@ export const makeDescribe = ( }; export const makeTest = ( - fn: Circus.TestFn | undefined, + fn: Circus.TestFn, mode: Circus.TestMode, name: Circus.TestName, parent: Circus.DescribeBlock, @@ -159,17 +159,18 @@ function checkIsError(error: unknown): error is Error { } export const callAsyncCircusFn = ( - fn: Circus.AsyncFn, + testOrHook: Circus.TestEntry | Circus.Hook, testContext: Circus.TestContext | undefined, - asyncError: Circus.Exception, - {isHook, timeout}: {isHook?: boolean | null; timeout: number}, + {isHook, timeout}: {isHook: boolean; timeout: number}, ): Promise => { let timeoutID: NodeJS.Timeout; let completed = false; + const {fn, asyncError} = testOrHook; + return new Promise((resolve, reject) => { timeoutID = setTimeout( - () => reject(_makeTimeoutMessage(timeout, !!isHook)), + () => reject(_makeTimeoutMessage(timeout, isHook)), timeout, ); @@ -179,7 +180,7 @@ export const callAsyncCircusFn = ( let returnedValue: unknown = undefined; const done = (reason?: Error | string): void => { // We need to keep a stack here before the promise tick - const errorAtDone = new Error(); + const errorAtDone = new ErrorWithStack(undefined, done); // Use `Promise.resolve` to allow the event loop to go a single tick in case `done` is called synchronously Promise.resolve().then(() => { if (returnedValue !== undefined) { diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index af3d023ad857..acae41e2cadf 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -1,21 +1,21 @@ { "name": "jest-cli", "description": "Delightful JavaScript Testing.", - "version": "26.5.3", + "version": "26.6.0", "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/core": "^26.5.3", - "@jest/test-result": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/core": "^26.6.0", + "@jest/test-result": "^26.6.0", + "@jest/types": "^26.6.0", "chalk": "^4.0.0", "exit": "^0.1.2", "graceful-fs": "^4.2.4", "import-local": "^3.0.2", "is-ci": "^2.0.0", - "jest-config": "^26.5.3", - "jest-util": "^26.5.2", - "jest-validate": "^26.5.3", + "jest-config": "^26.6.0", + "jest-util": "^26.6.0", + "jest-validate": "^26.6.0", "prompts": "^2.0.1", "yargs": "^15.4.1" }, diff --git a/packages/jest-cli/src/__tests__/cli/args.test.ts b/packages/jest-cli/src/__tests__/cli/args.test.ts index 55fe1255671d..5d2e5e5570e4 100644 --- a/packages/jest-cli/src/__tests__/cli/args.test.ts +++ b/packages/jest-cli/src/__tests__/cli/args.test.ts @@ -82,13 +82,13 @@ describe('check', () => { it('raises an exception if config is not a valid JSON string', () => { const argv = {config: 'x:1'} as Config.Argv; expect(() => check(argv)).toThrow( - 'The --config option requires a JSON string literal, or a file path with one of these extensions: .js, .mjs, .cjs, .json', + 'The --config option requires a JSON string literal, or a file path with one of these extensions: .js, .ts, .mjs, .cjs, .json', ); }); it('raises an exception if config is not a supported file type', () => { const message = - 'The --config option requires a JSON string literal, or a file path with one of these extensions: .js, .mjs, .cjs, .json'; + 'The --config option requires a JSON string literal, or a file path with one of these extensions: .js, .ts, .mjs, .cjs, .json'; expect(() => check({config: 'jest.configjs'} as Config.Argv)).toThrow( message, diff --git a/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap b/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap index 70e36b545cad..e90ed19aae3e 100644 --- a/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap +++ b/packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap @@ -45,9 +45,81 @@ Object { } `; +exports[`init has-jest-config-file-ts ask the user whether to override config or not user answered with "Yes" 1`] = ` +Object { + "initial": true, + "message": "It seems that you already have a jest configuration, do you want to override it?", + "name": "continue", + "type": "confirm", +} +`; + +exports[`init project using jest.config.ts ask the user whether he wants to use Typescript or not user answered with "Yes" 1`] = ` +Array [ + Object { + "initial": true, + "message": "Would you like to use Jest when running \\"test\\" script in \\"package.json\\"?", + "name": "scripts", + "type": "confirm", + }, + Object { + "initial": false, + "message": "Would you like to use Typescript for the configuration file?", + "name": "useTypescript", + "type": "confirm", + }, + Object { + "choices": Array [ + Object { + "title": "node", + "value": "node", + }, + Object { + "title": "jsdom (browser-like)", + "value": "jsdom", + }, + ], + "initial": 0, + "message": "Choose the test environment that will be used for testing", + "name": "environment", + "type": "select", + }, + Object { + "initial": false, + "message": "Do you want Jest to add coverage reports?", + "name": "coverage", + "type": "confirm", + }, + Object { + "choices": Array [ + Object { + "title": "v8", + "value": "v8", + }, + Object { + "title": "babel", + "value": "babel", + }, + ], + "initial": 0, + "message": "Which provider should be used to instrument code for coverage?", + "name": "coverageProvider", + "type": "select", + }, + Object { + "initial": false, + "message": "Automatically clear mock calls and instances between every test?", + "name": "clearMocks", + "type": "confirm", + }, +] +`; + exports[`init project with package.json and no jest config all questions answered with answer: "No" should return the default configuration (an empty config) 1`] = ` -"// For a detailed explanation regarding each configuration property, visit: -// https://jestjs.io/docs/en/configuration.html +"/* + * For a detailed explanation regarding each configuration property, visit: + * https://jestjs.io/docs/en/configuration.html + */ module.exports = { // All imported modules in your tests should be mocked automatically diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/jest.config.ts b/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/jest.config.ts new file mode 100644 index 000000000000..d291155b7a10 --- /dev/null +++ b/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/jest.config.ts @@ -0,0 +1,8 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export default {}; diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/package.json b/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/package.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/jest-cli/src/init/__tests__/fixtures/test_generated_jest_config_ts/package.json b/packages/jest-cli/src/init/__tests__/fixtures/test_generated_jest_config_ts/package.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/packages/jest-cli/src/init/__tests__/fixtures/test_generated_jest_config_ts/package.json @@ -0,0 +1 @@ +{} diff --git a/packages/jest-cli/src/init/__tests__/init.test.js b/packages/jest-cli/src/init/__tests__/init.test.js index e8b1b2fe1265..d8d820393c51 100644 --- a/packages/jest-cli/src/init/__tests__/init.test.js +++ b/packages/jest-cli/src/init/__tests__/init.test.js @@ -66,7 +66,7 @@ describe('init', () => { expect(writtenJestConfigFilename.endsWith('.mjs')).toBe(true); expect(typeof writtenJestConfig).toBe('string'); - expect(writtenJestConfig.split('\n')[3]).toBe('export default {'); + expect(writtenJestConfig.split('\n')[5]).toBe('export default {'); }); }); @@ -193,6 +193,34 @@ describe('init', () => { }, ); + describe('project using jest.config.ts', () => { + describe('ask the user whether he wants to use Typescript or not', () => { + it('user answered with "Yes"', async () => { + prompts.mockReturnValueOnce({useTypescript: true}); + + await init(resolveFromFixture('test_generated_jest_config_ts')); + + expect(prompts.mock.calls[0][0]).toMatchSnapshot(); + + const jestConfigFileName = fs.writeFileSync.mock.calls[0][0]; + const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; + + expect(jestConfigFileName).toContain('/jest.config.ts'); + expect(writtenJestConfig.split('\n')[5]).toBe('export default {'); + }); + + it('user answered with "No"', async () => { + prompts.mockReturnValueOnce({useTypescript: false}); + + await init(resolveFromFixture('test_generated_jest_config_ts')); + + const jestConfigFileName = fs.writeFileSync.mock.calls[0][0]; + + expect(jestConfigFileName).not.toContain('jest.config.ts'); + }); + }); + }); + describe('has jest config in package.json', () => { it('should ask the user whether to override config or not', async () => { prompts.mockReturnValueOnce({continue: true}).mockReturnValueOnce({}); diff --git a/packages/jest-cli/src/init/generate_config_file.ts b/packages/jest-cli/src/init/generate_config_file.ts index 4d7f8a428c3f..a7fdff6e277a 100644 --- a/packages/jest-cli/src/init/generate_config_file.ts +++ b/packages/jest-cli/src/init/generate_config_file.ts @@ -35,7 +35,13 @@ const generateConfigFile = ( results: Record, generateEsm = false, ): string => { - const {coverage, coverageProvider, clearMocks, environment} = results; + const { + useTypescript, + coverage, + coverageProvider, + clearMocks, + environment, + } = results; const overrides: Record = {}; @@ -81,10 +87,20 @@ const generateConfigFile = ( } } + const configHeaderMessage = `/* + * For a detailed explanation regarding each configuration property${ + useTypescript ? ' and type check' : '' + }, visit: + * https://jestjs.io/docs/en/configuration.html + */ + +`; + return ( - '// For a detailed explanation regarding each configuration property, visit:\n' + - '// https://jestjs.io/docs/en/configuration.html\n\n' + - (generateEsm ? 'export default {\n' : 'module.exports = {\n') + + configHeaderMessage + + (useTypescript || generateEsm + ? 'export default {\n' + : 'module.exports = {\n') + properties.join('\n') + '};\n' ); diff --git a/packages/jest-cli/src/init/index.ts b/packages/jest-cli/src/init/index.ts index 82b0fceffa4b..cdc5a5298ade 100644 --- a/packages/jest-cli/src/init/index.ts +++ b/packages/jest-cli/src/init/index.ts @@ -21,11 +21,13 @@ const { JEST_CONFIG_BASE_NAME, JEST_CONFIG_EXT_MJS, JEST_CONFIG_EXT_JS, + JEST_CONFIG_EXT_TS, JEST_CONFIG_EXT_ORDER, PACKAGE_JSON, } = constants; type PromptsResults = { + useTypescript: boolean; clearMocks: boolean; coverage: boolean; coverageProvider: boolean; @@ -64,16 +66,6 @@ export default async ( const existingJestConfigExt = JEST_CONFIG_EXT_ORDER.find(ext => fs.existsSync(path.join(rootDir, getConfigFilename(ext))), ); - const jestConfigPath = existingJestConfigExt - ? getConfigFilename(existingJestConfigExt) - : path.join( - rootDir, - getConfigFilename( - projectPackageJson.type === 'module' - ? JEST_CONFIG_EXT_MJS - : JEST_CONFIG_EXT_JS, - ), - ); if (hasJestProperty || existingJestConfigExt) { const result: {continue: boolean} = await prompts({ @@ -122,6 +114,18 @@ export default async ( return; } + // Determine if Jest should use JS or TS for the config file + const jestConfigFileExt = results.useTypescript + ? JEST_CONFIG_EXT_TS + : projectPackageJson.type === 'module' + ? JEST_CONFIG_EXT_MJS + : JEST_CONFIG_EXT_JS; + + // Determine Jest config path + const jestConfigPath = existingJestConfigExt + ? getConfigFilename(existingJestConfigExt) + : path.join(rootDir, getConfigFilename(jestConfigFileExt)); + const shouldModifyScripts = results.scripts; if (shouldModifyScripts || hasJestProperty) { diff --git a/packages/jest-cli/src/init/questions.ts b/packages/jest-cli/src/init/questions.ts index ae8671848b64..235411dc441a 100644 --- a/packages/jest-cli/src/init/questions.ts +++ b/packages/jest-cli/src/init/questions.ts @@ -8,6 +8,12 @@ import type {PromptObject} from 'prompts'; const defaultQuestions: Array = [ + { + initial: false, + message: 'Would you like to use Typescript for the configuration file?', + name: 'useTypescript', + type: 'confirm', + }, { choices: [ {title: 'node', value: 'node'}, diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 26df83ee27aa..ec2f9a451349 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -1,6 +1,6 @@ { "name": "jest-config", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -9,31 +9,41 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "peerDependencies": { + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "ts-node": { + "optional": true + } + }, "dependencies": { "@babel/core": "^7.1.0", - "@jest/test-sequencer": "^26.5.3", - "@jest/types": "^26.5.2", - "babel-jest": "^26.5.2", + "@jest/test-sequencer": "^26.6.0", + "@jest/types": "^26.6.0", + "babel-jest": "^26.6.0", "chalk": "^4.0.0", "deepmerge": "^4.2.2", "glob": "^7.1.1", "graceful-fs": "^4.2.4", - "jest-environment-jsdom": "^26.5.2", - "jest-environment-node": "^26.5.2", + "jest-environment-jsdom": "^26.6.0", + "jest-environment-node": "^26.6.0", "jest-get-type": "^26.3.0", - "jest-jasmine2": "^26.5.3", + "jest-jasmine2": "^26.6.0", "jest-regex-util": "^26.0.0", - "jest-resolve": "^26.5.2", - "jest-util": "^26.5.2", - "jest-validate": "^26.5.3", + "jest-resolve": "^26.6.0", + "jest-util": "^26.6.0", + "jest-validate": "^26.6.0", "micromatch": "^4.0.2", - "pretty-format": "^26.5.2" + "pretty-format": "^26.6.0" }, "devDependencies": { "@types/babel__core": "^7.0.4", "@types/glob": "^7.1.1", "@types/graceful-fs": "^4.1.3", - "@types/micromatch": "^4.0.0" + "@types/micromatch": "^4.0.0", + "ts-node": "^9.0.0", + "typescript": "^4.0.3" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-config/src/ValidConfig.ts b/packages/jest-config/src/ValidConfig.ts index c22337e0feaf..246c5c97f58e 100644 --- a/packages/jest-config/src/ValidConfig.ts +++ b/packages/jest-config/src/ValidConfig.ts @@ -119,7 +119,7 @@ const initialOptions: Config.InitialOptions = { testURL: 'http://localhost', timers: 'real', transform: { - '^.+\\.js$': '/preprocessor.js', + '\\.js$': '/preprocessor.js', }, transformIgnorePatterns: [NODE_MODULES_REGEXP], unmockedModulePathPatterns: ['mock'], diff --git a/packages/jest-config/src/__tests__/normalize.test.js b/packages/jest-config/src/__tests__/normalize.test.js index eb7ba42ad4a5..89ee1bdb2daa 100644 --- a/packages/jest-config/src/__tests__/normalize.test.js +++ b/packages/jest-config/src/__tests__/normalize.test.js @@ -14,7 +14,7 @@ import Defaults from '../Defaults'; import {DEFAULT_JS_PATTERN} from '../constants'; -const DEFAULT_CSS_PATTERN = '^.+\\.(css)$'; +const DEFAULT_CSS_PATTERN = '\\.(css)$'; jest .mock('jest-resolve') @@ -779,7 +779,7 @@ describe('babel-jest', () => { }); it('uses babel-jest if babel-jest is explicitly specified in a custom transform options', () => { - const customJSPattern = '^.+\\.js$'; + const customJSPattern = '\\.js$'; const {options} = normalize( { rootDir: '/root', diff --git a/packages/jest-config/src/__tests__/resolveConfigPath.test.ts b/packages/jest-config/src/__tests__/resolveConfigPath.test.ts index 0fba06b58295..b90166c73877 100644 --- a/packages/jest-config/src/__tests__/resolveConfigPath.test.ts +++ b/packages/jest-config/src/__tests__/resolveConfigPath.test.ts @@ -81,7 +81,7 @@ describe.each(JEST_CONFIG_EXT_ORDER.slice(0))( writeFiles(DIR, {[relativeJestConfigPath]: ''}); - // jest.config.js takes presedence + // jest.config.js takes precedence // absolute expect( diff --git a/packages/jest-config/src/constants.ts b/packages/jest-config/src/constants.ts index 3ae6c9701ece..d8abfc478bc1 100644 --- a/packages/jest-config/src/constants.ts +++ b/packages/jest-config/src/constants.ts @@ -8,16 +8,18 @@ import * as path from 'path'; export const NODE_MODULES = path.sep + 'node_modules' + path.sep; -export const DEFAULT_JS_PATTERN = '^.+\\.[jt]sx?$'; +export const DEFAULT_JS_PATTERN = '\\.[jt]sx?$'; export const DEFAULT_REPORTER_LABEL = 'default'; export const PACKAGE_JSON = 'package.json'; export const JEST_CONFIG_BASE_NAME = 'jest.config'; export const JEST_CONFIG_EXT_CJS = '.cjs'; export const JEST_CONFIG_EXT_MJS = '.mjs'; export const JEST_CONFIG_EXT_JS = '.js'; +export const JEST_CONFIG_EXT_TS = '.ts'; export const JEST_CONFIG_EXT_JSON = '.json'; export const JEST_CONFIG_EXT_ORDER = Object.freeze([ JEST_CONFIG_EXT_JS, + JEST_CONFIG_EXT_TS, JEST_CONFIG_EXT_MJS, JEST_CONFIG_EXT_CJS, JEST_CONFIG_EXT_JSON, diff --git a/packages/jest-config/src/index.ts b/packages/jest-config/src/index.ts index c0cc2326a7ec..17f930260df2 100644 --- a/packages/jest-config/src/index.ts +++ b/packages/jest-config/src/index.ts @@ -74,7 +74,7 @@ export async function readConfig( config.rootDir = config.rootDir || packageRootOrConfig; rawOptions = config; // A string passed to `--config`, which is either a direct path to the config - // or a path to directory containing `package.json` or `jest.config.js` + // or a path to directory containing `package.json`, `jest.config.js` or `jest.config.ts` } else if (!skipArgvConfigOption && typeof argv.config == 'string') { configPath = resolveConfigPath(argv.config, process.cwd()); rawOptions = await readConfigFileAndSetRootDir(configPath); diff --git a/packages/jest-config/src/readConfigFileAndSetRootDir.ts b/packages/jest-config/src/readConfigFileAndSetRootDir.ts index 06cbaecc10d6..47f1d6823efc 100644 --- a/packages/jest-config/src/readConfigFileAndSetRootDir.ts +++ b/packages/jest-config/src/readConfigFileAndSetRootDir.ts @@ -9,22 +9,34 @@ import * as path from 'path'; import {pathToFileURL} from 'url'; import * as fs from 'graceful-fs'; import type {Config} from '@jest/types'; +import {interopRequireDefault} from 'jest-util'; +import type {Register} from 'ts-node'; // @ts-expect-error: vendored import jsonlint from './vendor/jsonlint'; -import {JEST_CONFIG_EXT_JSON, PACKAGE_JSON} from './constants'; +import { + JEST_CONFIG_EXT_JSON, + JEST_CONFIG_EXT_TS, + PACKAGE_JSON, +} from './constants'; // Read the configuration and set its `rootDir` // 1. If it's a `package.json` file, we look into its "jest" property -// 2. For any other file, we just require it. If we receive an 'ERR_REQUIRE_ESM' +// 2. If it's a `jest.config.ts` file, we use `ts-node` to transpile & require it +// 3. For any other file, we just require it. If we receive an 'ERR_REQUIRE_ESM' // from node, perform a dynamic import instead. export default async function readConfigFileAndSetRootDir( configPath: Config.Path, ): Promise { + const isTS = configPath.endsWith(JEST_CONFIG_EXT_TS); const isJSON = configPath.endsWith(JEST_CONFIG_EXT_JSON); let configObject; try { - configObject = require(configPath); + if (isTS) { + configObject = await loadTSConfigFile(configPath); + } else { + configObject = require(configPath); + } } catch (error) { if (error.code === 'ERR_REQUIRE_ESM') { try { @@ -54,6 +66,11 @@ export default async function readConfigFileAndSetRootDir( `Jest: Failed to parse config file ${configPath}\n` + ` ${jsonlint.errors(fs.readFileSync(configPath, 'utf8'))}`, ); + } else if (isTS) { + throw new Error( + `Jest: Failed to parse the TypeScript config file ${configPath}\n` + + ` ${error}`, + ); } else { throw error; } @@ -81,3 +98,36 @@ export default async function readConfigFileAndSetRootDir( return configObject; } + +// Load the TypeScript configuration +const loadTSConfigFile = async ( + configPath: Config.Path, +): Promise => { + let registerer: Register; + + // Register TypeScript compiler instance + try { + registerer = require('ts-node').register(); + } catch (e) { + if (e.code === 'MODULE_NOT_FOUND') { + throw new Error( + `Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed\nError: ${e.message}`, + ); + } + + throw e; + } + + registerer.enabled(true); + + let configObject = interopRequireDefault(require(configPath)).default; + + // In case the config is a function which imports more Typescript code + if (typeof configObject === 'function') { + configObject = await configObject(); + } + + registerer.enabled(false); + + return configObject; +}; diff --git a/packages/jest-console/package.json b/packages/jest-console/package.json index b0e667672776..14932f92459b 100644 --- a/packages/jest-console/package.json +++ b/packages/jest-console/package.json @@ -1,6 +1,6 @@ { "name": "@jest/console", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,11 +10,11 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "@types/node": "*", "chalk": "^4.0.0", - "jest-message-util": "^26.5.2", - "jest-util": "^26.5.2", + "jest-message-util": "^26.6.0", + "jest-util": "^26.6.0", "slash": "^3.0.0" }, "devDependencies": { diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index d8058925c5f6..853d668a7c82 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -1,33 +1,33 @@ { "name": "@jest/core", "description": "Delightful JavaScript Testing.", - "version": "26.5.3", + "version": "26.6.0", "main": "build/jest.js", "types": "build/jest.d.ts", "dependencies": { - "@jest/console": "^26.5.2", - "@jest/reporters": "^26.5.3", - "@jest/test-result": "^26.5.2", - "@jest/transform": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/console": "^26.6.0", + "@jest/reporters": "^26.6.0", + "@jest/test-result": "^26.6.0", + "@jest/transform": "^26.6.0", + "@jest/types": "^26.6.0", "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", "exit": "^0.1.2", "graceful-fs": "^4.2.4", - "jest-changed-files": "^26.5.2", - "jest-config": "^26.5.3", - "jest-haste-map": "^26.5.2", - "jest-message-util": "^26.5.2", + "jest-changed-files": "^26.6.0", + "jest-config": "^26.6.0", + "jest-haste-map": "^26.6.0", + "jest-message-util": "^26.6.0", "jest-regex-util": "^26.0.0", - "jest-resolve": "^26.5.2", - "jest-resolve-dependencies": "^26.5.3", - "jest-runner": "^26.5.3", - "jest-runtime": "^26.5.3", - "jest-snapshot": "^26.5.3", - "jest-util": "^26.5.2", - "jest-validate": "^26.5.3", - "jest-watcher": "^26.5.2", + "jest-resolve": "^26.6.0", + "jest-resolve-dependencies": "^26.6.0", + "jest-runner": "^26.6.0", + "jest-runtime": "^26.6.0", + "jest-snapshot": "^26.6.0", + "jest-util": "^26.6.0", + "jest-validate": "^26.6.0", + "jest-watcher": "^26.6.0", "micromatch": "^4.0.2", "p-each-series": "^2.1.0", "rimraf": "^3.0.0", @@ -35,7 +35,7 @@ "strip-ansi": "^6.0.0" }, "devDependencies": { - "@jest/test-sequencer": "^26.5.3", + "@jest/test-sequencer": "^26.6.0", "@types/exit": "^0.1.30", "@types/graceful-fs": "^4.1.2", "@types/micromatch": "^4.0.0", diff --git a/packages/jest-diff/package.json b/packages/jest-diff/package.json index 7bc3c86ea978..05e4a29f0166 100644 --- a/packages/jest-diff/package.json +++ b/packages/jest-diff/package.json @@ -1,6 +1,6 @@ { "name": "jest-diff", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -13,7 +13,7 @@ "chalk": "^4.0.0", "diff-sequences": "^26.5.0", "jest-get-type": "^26.3.0", - "pretty-format": "^26.5.2" + "pretty-format": "^26.6.0" }, "devDependencies": { "@jest/test-utils": "^26.5.0", diff --git a/packages/jest-each/package.json b/packages/jest-each/package.json index f55892f89e47..b7b0eb1f5182 100644 --- a/packages/jest-each/package.json +++ b/packages/jest-each/package.json @@ -1,6 +1,6 @@ { "name": "jest-each", - "version": "26.5.2", + "version": "26.6.0", "description": "Parameterised tests for Jest", "main": "build/index.js", "types": "build/index.d.ts", @@ -18,11 +18,11 @@ "author": "Matt Phillips (mattphillips)", "license": "MIT", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "chalk": "^4.0.0", "jest-get-type": "^26.3.0", - "jest-util": "^26.5.2", - "pretty-format": "^26.5.2" + "jest-util": "^26.6.0", + "pretty-format": "^26.6.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index 2339dbb7f060..a51633ca0bdc 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -1,6 +1,6 @@ { "name": "jest-environment-jsdom", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,12 +10,12 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/environment": "^26.5.2", - "@jest/fake-timers": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/environment": "^26.6.0", + "@jest/fake-timers": "^26.6.0", + "@jest/types": "^26.6.0", "@types/node": "*", - "jest-mock": "^26.5.2", - "jest-util": "^26.5.2", + "jest-mock": "^26.6.0", + "jest-util": "^26.6.0", "jsdom": "^16.4.0" }, "devDependencies": { diff --git a/packages/jest-environment-node/package.json b/packages/jest-environment-node/package.json index c3068627bb40..fc18f0a1329e 100644 --- a/packages/jest-environment-node/package.json +++ b/packages/jest-environment-node/package.json @@ -1,6 +1,6 @@ { "name": "jest-environment-node", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,12 +10,12 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/environment": "^26.5.2", - "@jest/fake-timers": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/environment": "^26.6.0", + "@jest/fake-timers": "^26.6.0", + "@jest/types": "^26.6.0", "@types/node": "*", - "jest-mock": "^26.5.2", - "jest-util": "^26.5.2" + "jest-mock": "^26.6.0", + "jest-util": "^26.6.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json index 650beccfbacf..637e6c6a6105 100644 --- a/packages/jest-environment/package.json +++ b/packages/jest-environment/package.json @@ -1,6 +1,6 @@ { "name": "@jest/environment", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,10 +10,10 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/fake-timers": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/fake-timers": "^26.6.0", + "@jest/types": "^26.6.0", "@types/node": "*", - "jest-mock": "^26.5.2" + "jest-mock": "^26.6.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index ac2d46b63d30..d241b82edbf2 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -1,6 +1,6 @@ { "name": "@jest/fake-timers", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,12 +10,12 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "@sinonjs/fake-timers": "^6.0.1", "@types/node": "*", - "jest-message-util": "^26.5.2", - "jest-mock": "^26.5.2", - "jest-util": "^26.5.2" + "jest-message-util": "^26.6.0", + "jest-mock": "^26.6.0", + "jest-util": "^26.6.0" }, "devDependencies": { "@types/sinonjs__fake-timers": "^6.0.1" diff --git a/packages/jest-fake-timers/src/legacyFakeTimers.ts b/packages/jest-fake-timers/src/legacyFakeTimers.ts index 66be88c2518f..cb7a2abab30c 100644 --- a/packages/jest-fake-timers/src/legacyFakeTimers.ts +++ b/packages/jest-fake-timers/src/legacyFakeTimers.ts @@ -94,7 +94,6 @@ export default class FakeTimers { }; this.reset(); - this._createMocks(); } clearAllTimers(): void { @@ -349,7 +348,7 @@ export default class FakeTimers { } private _checkFakeTimers() { - if (this._global.setTimeout !== this._fakeTimerAPIs.setTimeout) { + if (this._global.setTimeout !== this._fakeTimerAPIs?.setTimeout) { this._global.console.warn( `A function to advance timers was called but the timers API is not ` + `mocked with fake timers. Call \`jest.useFakeTimers()\` in this ` + diff --git a/packages/jest-globals/package.json b/packages/jest-globals/package.json index 3e6034d0de80..2de890cb59e7 100644 --- a/packages/jest-globals/package.json +++ b/packages/jest-globals/package.json @@ -1,6 +1,6 @@ { "name": "@jest/globals", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -13,9 +13,9 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/environment": "^26.5.2", - "@jest/types": "^26.5.2", - "expect": "^26.5.3" + "@jest/environment": "^26.6.0", + "@jest/types": "^26.6.0", + "expect": "^26.6.0" }, "publishConfig": { "access": "public" diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index b82c2554165e..319388eb2523 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -1,6 +1,6 @@ { "name": "jest-haste-map", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,7 +10,7 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "@types/graceful-fs": "^4.1.2", "@types/node": "*", "anymatch": "^3.0.3", @@ -18,7 +18,7 @@ "graceful-fs": "^4.2.4", "jest-regex-util": "^26.0.0", "jest-serializer": "^26.5.0", - "jest-util": "^26.5.2", + "jest-util": "^26.6.0", "jest-worker": "^26.5.0", "micromatch": "^4.0.2", "sane": "^4.0.3", diff --git a/packages/jest-jasmine2/package.json b/packages/jest-jasmine2/package.json index 7c750a666e08..991a40a654b6 100644 --- a/packages/jest-jasmine2/package.json +++ b/packages/jest-jasmine2/package.json @@ -1,6 +1,6 @@ { "name": "jest-jasmine2", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -11,22 +11,22 @@ "types": "build/index.d.ts", "dependencies": { "@babel/traverse": "^7.1.0", - "@jest/environment": "^26.5.2", + "@jest/environment": "^26.6.0", "@jest/source-map": "^26.5.0", - "@jest/test-result": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/test-result": "^26.6.0", + "@jest/types": "^26.6.0", "@types/node": "*", "chalk": "^4.0.0", "co": "^4.6.0", - "expect": "^26.5.3", + "expect": "^26.6.0", "is-generator-fn": "^2.0.0", - "jest-each": "^26.5.2", - "jest-matcher-utils": "^26.5.2", - "jest-message-util": "^26.5.2", - "jest-runtime": "^26.5.3", - "jest-snapshot": "^26.5.3", - "jest-util": "^26.5.2", - "pretty-format": "^26.5.2", + "jest-each": "^26.6.0", + "jest-matcher-utils": "^26.6.0", + "jest-message-util": "^26.6.0", + "jest-runtime": "^26.6.0", + "jest-snapshot": "^26.6.0", + "jest-util": "^26.6.0", + "pretty-format": "^26.6.0", "throat": "^5.0.0" }, "devDependencies": { diff --git a/packages/jest-leak-detector/package.json b/packages/jest-leak-detector/package.json index 0f25786ba597..653929183c32 100644 --- a/packages/jest-leak-detector/package.json +++ b/packages/jest-leak-detector/package.json @@ -1,6 +1,6 @@ { "name": "jest-leak-detector", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -11,7 +11,7 @@ "types": "build/index.d.ts", "dependencies": { "jest-get-type": "^26.3.0", - "pretty-format": "^26.5.2" + "pretty-format": "^26.6.0" }, "devDependencies": { "@types/weak-napi": "^2.0.0", diff --git a/packages/jest-matcher-utils/package.json b/packages/jest-matcher-utils/package.json index 82ad31946ee0..914e43c01ca6 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": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -15,9 +15,9 @@ "types": "build/index.d.ts", "dependencies": { "chalk": "^4.0.0", - "jest-diff": "^26.5.2", + "jest-diff": "^26.6.0", "jest-get-type": "^26.3.0", - "pretty-format": "^26.5.2" + "pretty-format": "^26.6.0" }, "devDependencies": { "@jest/test-utils": "^26.5.0", diff --git a/packages/jest-message-util/package.json b/packages/jest-message-util/package.json index 861cb0925b0b..63f191be446d 100644 --- a/packages/jest-message-util/package.json +++ b/packages/jest-message-util/package.json @@ -1,6 +1,6 @@ { "name": "jest-message-util", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -14,7 +14,7 @@ "types": "build/index.d.ts", "dependencies": { "@babel/code-frame": "^7.0.0", - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", "graceful-fs": "^4.2.4", diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index 98bb58c8c982..269dce26c2a9 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -1,6 +1,6 @@ { "name": "jest-mock", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,7 +10,7 @@ "node": ">= 10.14.2" }, "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "@types/node": "*" }, "license": "MIT", diff --git a/packages/jest-phabricator/package.json b/packages/jest-phabricator/package.json index b54e1cd4f778..ca9b70632a61 100644 --- a/packages/jest-phabricator/package.json +++ b/packages/jest-phabricator/package.json @@ -1,6 +1,6 @@ { "name": "jest-phabricator", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -8,7 +8,7 @@ }, "types": "build/index.d.ts", "dependencies": { - "@jest/test-result": "^26.5.2" + "@jest/test-result": "^26.6.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index e37e9f76df3a..02ce6a85ab2e 100644 --- a/packages/jest-repl/package.json +++ b/packages/jest-repl/package.json @@ -1,6 +1,6 @@ { "name": "jest-repl", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,11 +10,11 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/transform": "^26.5.2", - "@jest/types": "^26.5.2", - "jest-config": "^26.5.3", - "jest-runtime": "^26.5.3", - "jest-validate": "^26.5.3", + "@jest/transform": "^26.6.0", + "@jest/types": "^26.6.0", + "jest-config": "^26.6.0", + "jest-runtime": "^26.6.0", + "jest-validate": "^26.6.0", "repl": "^0.1.3", "yargs": "^15.4.1" }, diff --git a/packages/jest-reporters/package.json b/packages/jest-reporters/package.json index 35270cdf38f1..c0df7c963f15 100644 --- a/packages/jest-reporters/package.json +++ b/packages/jest-reporters/package.json @@ -1,15 +1,15 @@ { "name": "@jest/reporters", "description": "Jest's reporters", - "version": "26.5.3", + "version": "26.6.0", "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { "@bcoe/v8-coverage": "^0.2.3", - "@jest/console": "^26.5.2", - "@jest/test-result": "^26.5.2", - "@jest/transform": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/console": "^26.6.0", + "@jest/test-result": "^26.6.0", + "@jest/transform": "^26.6.0", + "@jest/types": "^26.6.0", "chalk": "^4.0.0", "collect-v8-coverage": "^1.0.0", "exit": "^0.1.2", @@ -20,9 +20,9 @@ "istanbul-lib-report": "^3.0.0", "istanbul-lib-source-maps": "^4.0.0", "istanbul-reports": "^3.0.2", - "jest-haste-map": "^26.5.2", - "jest-resolve": "^26.5.2", - "jest-util": "^26.5.2", + "jest-haste-map": "^26.6.0", + "jest-resolve": "^26.6.0", + "jest-util": "^26.6.0", "jest-worker": "^26.5.0", "slash": "^3.0.0", "source-map": "^0.6.0", diff --git a/packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js b/packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js index 08f0e0958183..1142e0d449db 100644 --- a/packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js +++ b/packages/jest-reporters/src/__tests__/generateEmptyCoverage.test.js @@ -51,7 +51,7 @@ describe('generateEmptyCoverage', () => { cacheDirectory: os.tmpdir(), cwd: rootDir, rootDir, - transform: [['^.+\\.js$', require.resolve('babel-jest')]], + transform: [['\\.js$', require.resolve('babel-jest')]], }), ); @@ -95,7 +95,7 @@ describe('generateEmptyCoverage', () => { cacheDirectory: os.tmpdir(), cwd: rootDir, rootDir, - transform: [['^.+\\.js$', require.resolve('babel-jest')]], + transform: [['\\.js$', require.resolve('babel-jest')]], }), ); @@ -124,7 +124,7 @@ describe('generateEmptyCoverage', () => { cacheDirectory: os.tmpdir(), cwd: rootDir, rootDir, - transform: [['^.+\\.js$', require.resolve('babel-jest')]], + transform: [['\\.js$', require.resolve('babel-jest')]], }), ); diff --git a/packages/jest-resolve-dependencies/package.json b/packages/jest-resolve-dependencies/package.json index 1f9b1425e755..337d2ba32f02 100644 --- a/packages/jest-resolve-dependencies/package.json +++ b/packages/jest-resolve-dependencies/package.json @@ -1,6 +1,6 @@ { "name": "jest-resolve-dependencies", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,14 +10,14 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "jest-regex-util": "^26.0.0", - "jest-snapshot": "^26.5.3" + "jest-snapshot": "^26.6.0" }, "devDependencies": { - "jest-haste-map": "^26.5.2", - "jest-resolve": "^26.5.2", - "jest-runtime": "^26.5.3" + "jest-haste-map": "^26.6.0", + "jest-resolve": "^26.6.0", + "jest-runtime": "^26.6.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-resolve/package.json b/packages/jest-resolve/package.json index ad9d8aab38a6..dd0a7bc5f842 100644 --- a/packages/jest-resolve/package.json +++ b/packages/jest-resolve/package.json @@ -1,6 +1,6 @@ { "name": "jest-resolve", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,11 +10,11 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "chalk": "^4.0.0", "graceful-fs": "^4.2.4", "jest-pnp-resolver": "^1.2.2", - "jest-util": "^26.5.2", + "jest-util": "^26.6.0", "read-pkg-up": "^7.0.1", "resolve": "^1.17.0", "slash": "^3.0.0" @@ -22,7 +22,7 @@ "devDependencies": { "@types/graceful-fs": "^4.1.3", "@types/resolve": "^1.17.0", - "jest-haste-map": "^26.5.2" + "jest-haste-map": "^26.6.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index 7fd691b2881b..b7571199b54c 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -1,6 +1,6 @@ { "name": "jest-runner", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,23 +10,23 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/console": "^26.5.2", - "@jest/environment": "^26.5.2", - "@jest/test-result": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/console": "^26.6.0", + "@jest/environment": "^26.6.0", + "@jest/test-result": "^26.6.0", + "@jest/types": "^26.6.0", "@types/node": "*", "chalk": "^4.0.0", "emittery": "^0.7.1", "exit": "^0.1.2", "graceful-fs": "^4.2.4", - "jest-config": "^26.5.3", + "jest-config": "^26.6.0", "jest-docblock": "^26.0.0", - "jest-haste-map": "^26.5.2", - "jest-leak-detector": "^26.5.2", - "jest-message-util": "^26.5.2", - "jest-resolve": "^26.5.2", - "jest-runtime": "^26.5.3", - "jest-util": "^26.5.2", + "jest-haste-map": "^26.6.0", + "jest-leak-detector": "^26.6.0", + "jest-message-util": "^26.6.0", + "jest-resolve": "^26.6.0", + "jest-runtime": "^26.6.0", + "jest-util": "^26.6.0", "jest-worker": "^26.5.0", "source-map-support": "^0.5.6", "throat": "^5.0.0" @@ -35,7 +35,7 @@ "@types/exit": "^0.1.30", "@types/graceful-fs": "^4.1.2", "@types/source-map-support": "^0.5.0", - "jest-circus": "^26.5.3" + "jest-circus": "^26.6.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-runtime/package.json b/packages/jest-runtime/package.json index aef66c368149..b4c126c4f14d 100644 --- a/packages/jest-runtime/package.json +++ b/packages/jest-runtime/package.json @@ -1,6 +1,6 @@ { "name": "jest-runtime", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,29 +10,29 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/console": "^26.5.2", - "@jest/environment": "^26.5.2", - "@jest/fake-timers": "^26.5.2", - "@jest/globals": "^26.5.3", + "@jest/console": "^26.6.0", + "@jest/environment": "^26.6.0", + "@jest/fake-timers": "^26.6.0", + "@jest/globals": "^26.6.0", "@jest/source-map": "^26.5.0", - "@jest/test-result": "^26.5.2", - "@jest/transform": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/test-result": "^26.6.0", + "@jest/transform": "^26.6.0", + "@jest/types": "^26.6.0", "@types/yargs": "^15.0.0", "chalk": "^4.0.0", "collect-v8-coverage": "^1.0.0", "exit": "^0.1.2", "glob": "^7.1.3", "graceful-fs": "^4.2.4", - "jest-config": "^26.5.3", - "jest-haste-map": "^26.5.2", - "jest-message-util": "^26.5.2", - "jest-mock": "^26.5.2", + "jest-config": "^26.6.0", + "jest-haste-map": "^26.6.0", + "jest-message-util": "^26.6.0", + "jest-mock": "^26.6.0", "jest-regex-util": "^26.0.0", - "jest-resolve": "^26.5.2", - "jest-snapshot": "^26.5.3", - "jest-util": "^26.5.2", - "jest-validate": "^26.5.3", + "jest-resolve": "^26.6.0", + "jest-snapshot": "^26.6.0", + "jest-util": "^26.6.0", + "jest-validate": "^26.6.0", "slash": "^3.0.0", "strip-bom": "^4.0.0", "yargs": "^15.4.1" @@ -44,7 +44,7 @@ "@types/graceful-fs": "^4.1.2", "@types/node": "^14.0.27", "execa": "^4.0.0", - "jest-environment-node": "^26.5.2", + "jest-environment-node": "^26.6.0", "jest-snapshot-serializer-raw": "^1.1.0" }, "bin": "./bin/jest-runtime.js", diff --git a/packages/jest-runtime/src/__tests__/runtime_internal_module.test.js b/packages/jest-runtime/src/__tests__/runtime_internal_module.test.js index 7ed833b9f4a9..3c6653f3cebe 100644 --- a/packages/jest-runtime/src/__tests__/runtime_internal_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_internal_module.test.js @@ -22,7 +22,7 @@ describe('Runtime', () => { describe('internalModule', () => { it('loads modules and applies transforms', () => createRuntime(__filename, { - transform: {'^.+\\.js$': './test_preprocessor'}, + transform: {'\\.js$': './test_preprocessor'}, }).then(runtime => { const modulePath = path.resolve( path.dirname(runtime.__mockRootPath), @@ -35,7 +35,7 @@ describe('Runtime', () => { it('loads internal modules without applying transforms', () => createRuntime(__filename, { - transform: {'^.+\\.js$': './test_preprocessor'}, + transform: {'\\.js$': './test_preprocessor'}, }).then(runtime => { const modulePath = path.resolve( path.dirname(runtime.__mockRootPath), @@ -47,7 +47,7 @@ describe('Runtime', () => { it('loads JSON modules and applies transforms', () => createRuntime(__filename, { - transform: {'^.+\\.json$': './test_json_preprocessor'}, + transform: {'\\.json$': './test_json_preprocessor'}, }).then(runtime => { const modulePath = path.resolve( path.dirname(runtime.__mockRootPath), @@ -59,7 +59,7 @@ describe('Runtime', () => { it('loads internal JSON modules without applying transforms', () => createRuntime(__filename, { - transform: {'^.+\\.json$': './test_json_preprocessor'}, + transform: {'\\.json$': './test_json_preprocessor'}, }).then(runtime => { const modulePath = path.resolve( path.dirname(runtime.__mockRootPath), diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index d9dec727507f..244222b294a1 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -139,7 +139,7 @@ describe('Runtime requireModule', () => { }); it('provides `require.main` to modules', () => createRuntime(__filename).then(runtime => { - runtime._moduleRegistry.set(__filename, module); + runtime._mainModule = module; [ './test_root/modules_with_main/export_main.js', './test_root/modules_with_main/re_export_main.js', diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index b8c2fee5da1f..b19b0dbf1cce 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -1400,8 +1400,9 @@ class Runtime { Object.defineProperty(moduleRequire, 'main', { enumerable: true, - value: this._testPath ? this._moduleRegistry.get(this._testPath) : null, + value: this._mainModule, }); + return moduleRequire; } diff --git a/packages/jest-snapshot/package.json b/packages/jest-snapshot/package.json index 037a86f7d272..719bfe69cb97 100644 --- a/packages/jest-snapshot/package.json +++ b/packages/jest-snapshot/package.json @@ -1,6 +1,6 @@ { "name": "jest-snapshot", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -11,20 +11,20 @@ "types": "build/index.d.ts", "dependencies": { "@babel/types": "^7.0.0", - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "@types/babel__traverse": "^7.0.4", "@types/prettier": "^2.0.0", "chalk": "^4.0.0", - "expect": "^26.5.3", + "expect": "^26.6.0", "graceful-fs": "^4.2.4", - "jest-diff": "^26.5.2", + "jest-diff": "^26.6.0", "jest-get-type": "^26.3.0", - "jest-haste-map": "^26.5.2", - "jest-matcher-utils": "^26.5.2", - "jest-message-util": "^26.5.2", - "jest-resolve": "^26.5.2", + "jest-haste-map": "^26.6.0", + "jest-matcher-utils": "^26.6.0", + "jest-message-util": "^26.6.0", + "jest-resolve": "^26.6.0", "natural-compare": "^1.4.0", - "pretty-format": "^26.5.2", + "pretty-format": "^26.6.0", "semver": "^7.3.2" }, "devDependencies": { diff --git a/packages/jest-test-result/package.json b/packages/jest-test-result/package.json index e1294fb601c1..c23bd826acf3 100644 --- a/packages/jest-test-result/package.json +++ b/packages/jest-test-result/package.json @@ -1,6 +1,6 @@ { "name": "@jest/test-result", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,8 +10,8 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/console": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/console": "^26.6.0", + "@jest/types": "^26.6.0", "@types/istanbul-lib-coverage": "^2.0.0", "collect-v8-coverage": "^1.0.0" }, diff --git a/packages/jest-test-sequencer/package.json b/packages/jest-test-sequencer/package.json index c6ab13765416..451b893dd845 100644 --- a/packages/jest-test-sequencer/package.json +++ b/packages/jest-test-sequencer/package.json @@ -1,6 +1,6 @@ { "name": "@jest/test-sequencer", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,11 +10,11 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/test-result": "^26.5.2", + "@jest/test-result": "^26.6.0", "graceful-fs": "^4.2.4", - "jest-haste-map": "^26.5.2", - "jest-runner": "^26.5.3", - "jest-runtime": "^26.5.3" + "jest-haste-map": "^26.6.0", + "jest-runner": "^26.6.0", + "jest-runtime": "^26.6.0" }, "devDependencies": { "@types/graceful-fs": "^4.1.3" diff --git a/packages/jest-transform/package.json b/packages/jest-transform/package.json index b9982cc9df9f..44f717218c9e 100644 --- a/packages/jest-transform/package.json +++ b/packages/jest-transform/package.json @@ -1,6 +1,6 @@ { "name": "@jest/transform", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -11,15 +11,15 @@ "types": "build/index.d.ts", "dependencies": { "@babel/core": "^7.1.0", - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "babel-plugin-istanbul": "^6.0.0", "chalk": "^4.0.0", "convert-source-map": "^1.4.0", "fast-json-stable-stringify": "^2.0.0", "graceful-fs": "^4.2.4", - "jest-haste-map": "^26.5.2", + "jest-haste-map": "^26.6.0", "jest-regex-util": "^26.0.0", - "jest-util": "^26.5.2", + "jest-util": "^26.6.0", "micromatch": "^4.0.2", "pirates": "^4.0.1", "slash": "^3.0.0", diff --git a/packages/jest-transform/src/__tests__/__snapshots__/script_transformer.test.js.snap b/packages/jest-transform/src/__tests__/__snapshots__/script_transformer.test.js.snap index a88f709e8eb4..22150f9be8c5 100644 --- a/packages/jest-transform/src/__tests__/__snapshots__/script_transformer.test.js.snap +++ b/packages/jest-transform/src/__tests__/__snapshots__/script_transformer.test.js.snap @@ -58,7 +58,7 @@ Object { "timers": "real", "transform": Array [ Array [ - "^.+\\\\.js$", + "\\\\.js$", "test_preprocessor", ], ], @@ -231,7 +231,7 @@ exports[`ScriptTransformer uses multiple preprocessors 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-jasmine2","testURL":"http://localhost","timers":"real","transform":[["^.+\\\\.js$","test_preprocessor"],["^.+\\\\.css$","css-preprocessor"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]}', + config: '{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-jasmine2","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_preprocessor"],["\\\\.css$","css-preprocessor"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]}', }; `; @@ -248,7 +248,7 @@ exports[`ScriptTransformer uses the supplied preprocessor 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-jasmine2","testURL":"http://localhost","timers":"real","transform":[["^.+\\\\.js$","test_preprocessor"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]}', + config: '{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-jasmine2","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_preprocessor"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]}', }; `; diff --git a/packages/jest-transform/src/__tests__/script_transformer.test.js b/packages/jest-transform/src/__tests__/script_transformer.test.js index fd8c31d2b007..f81c63f0453c 100644 --- a/packages/jest-transform/src/__tests__/script_transformer.test.js +++ b/packages/jest-transform/src/__tests__/script_transformer.test.js @@ -281,7 +281,7 @@ describe('ScriptTransformer', () => { () => { config = { ...config, - transform: [['^.+\\.js$', 'passthrough-preprocessor']], + transform: [['\\.js$', 'passthrough-preprocessor']], }; const scriptTransformer = new ScriptTransformer(config); @@ -317,7 +317,7 @@ describe('ScriptTransformer', () => { it("throws an error if `process` doesn't defined", () => { config = { ...config, - transform: [['^.+\\.js$', 'skipped-required-props-preprocessor']], + transform: [['\\.js$', 'skipped-required-props-preprocessor']], }; const scriptTransformer = new ScriptTransformer(config); expect(() => @@ -329,7 +329,7 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['^.+\\.js$', 'skipped-required-create-transformer-props-preprocessor'], + ['\\.js$', 'skipped-required-create-transformer-props-preprocessor'], ], }; const scriptTransformer = new ScriptTransformer(config); @@ -341,7 +341,7 @@ describe('ScriptTransformer', () => { it("shouldn't throw error without process method. But with corrent createTransformer method", () => { config = { ...config, - transform: [['^.+\\.js$', 'skipped-process-method-preprocessor']], + transform: [['\\.js$', 'skipped-process-method-preprocessor']], }; const scriptTransformer = new ScriptTransformer(config); expect(() => @@ -350,7 +350,7 @@ describe('ScriptTransformer', () => { }); it('uses the supplied preprocessor', () => { - config = {...config, transform: [['^.+\\.js$', 'test_preprocessor']]}; + config = {...config, transform: [['\\.js$', 'test_preprocessor']]}; const scriptTransformer = new ScriptTransformer(config); const res1 = scriptTransformer.transform('/fruits/banana.js', {}); @@ -367,8 +367,8 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['^.+\\.js$', 'test_preprocessor'], - ['^.+\\.css$', 'css-preprocessor'], + ['\\.js$', 'test_preprocessor'], + ['\\.css$', 'css-preprocessor'], ], }; const scriptTransformer = new ScriptTransformer(config); @@ -389,7 +389,7 @@ describe('ScriptTransformer', () => { it('writes source map if preprocessor supplies it', () => { config = { ...config, - transform: [['^.+\\.js$', 'preprocessor-with-sourcemaps']], + transform: [['\\.js$', 'preprocessor-with-sourcemaps']], }; const scriptTransformer = new ScriptTransformer(config); @@ -419,7 +419,7 @@ describe('ScriptTransformer', () => { it('writes source map if preprocessor inlines it', () => { config = { ...config, - transform: [['^.+\\.js$', 'preprocessor-with-sourcemaps']], + transform: [['\\.js$', 'preprocessor-with-sourcemaps']], }; const scriptTransformer = new ScriptTransformer(config); @@ -454,7 +454,7 @@ describe('ScriptTransformer', () => { config = { ...config, - transform: [['^.+\\.js$', 'preprocessor-with-sourcemaps']], + transform: [['\\.js$', 'preprocessor-with-sourcemaps']], }; const scriptTransformer = new ScriptTransformer(config); @@ -488,7 +488,7 @@ describe('ScriptTransformer', () => { it('writes source maps if given by the transformer', () => { config = { ...config, - transform: [['^.+\\.js$', 'preprocessor-with-sourcemaps']], + transform: [['\\.js$', 'preprocessor-with-sourcemaps']], }; const scriptTransformer = new ScriptTransformer(config); @@ -521,7 +521,7 @@ describe('ScriptTransformer', () => { it('does not write source map if not given by the transformer', () => { config = { ...config, - transform: [['^.+\\.js$', 'preprocessor-with-sourcemaps']], + transform: [['\\.js$', 'preprocessor-with-sourcemaps']], }; const scriptTransformer = new ScriptTransformer(config); @@ -543,7 +543,7 @@ describe('ScriptTransformer', () => { it('should write a source map for the instrumented file when transformed', () => { const transformerConfig = { ...config, - transform: [['^.+\\.js$', 'preprocessor-with-sourcemaps']], + transform: [['\\.js$', 'preprocessor-with-sourcemaps']], }; const scriptTransformer = new ScriptTransformer(transformerConfig); @@ -626,7 +626,7 @@ describe('ScriptTransformer', () => { }); it('passes expected transform options to getCacheKey', () => { - config = {...config, transform: [['^.+\\.js$', 'test_preprocessor']]}; + config = {...config, transform: [['\\.js$', 'test_preprocessor']]}; const scriptTransformer = new ScriptTransformer(config); scriptTransformer.transform( @@ -643,9 +643,7 @@ describe('ScriptTransformer', () => { it('creates transformer with config', () => { const transformerConfig = {}; config = Object.assign(config, { - transform: [ - ['^.+\\.js$', 'configureable-preprocessor', transformerConfig], - ], + transform: [['\\.js$', 'configureable-preprocessor', transformerConfig]], }); const scriptTransformer = new ScriptTransformer(config); @@ -658,7 +656,7 @@ describe('ScriptTransformer', () => { it('reads values from the cache', () => { const transformConfig = { ...config, - transform: [['^.+\\.js$', 'test_preprocessor']], + transform: [['\\.js$', 'test_preprocessor']], }; let scriptTransformer = new ScriptTransformer(transformConfig); scriptTransformer.transform('/fruits/banana.js', {}); @@ -699,7 +697,7 @@ describe('ScriptTransformer', () => { it('reads values from the cache when the file contains colons', () => { const transformConfig = { ...config, - transform: [['^.+\\.js$', 'test_preprocessor']], + transform: [['\\.js$', 'test_preprocessor']], }; let scriptTransformer = new ScriptTransformer(transformConfig); scriptTransformer.transform('/fruits/banana:colon.js', {}); @@ -727,14 +725,14 @@ describe('ScriptTransformer', () => { it('does not reuse the in-memory cache between different projects', () => { const scriptTransformer = new ScriptTransformer({ ...config, - transform: [['^.+\\.js$', 'test_preprocessor']], + transform: [['\\.js$', 'test_preprocessor']], }); scriptTransformer.transform('/fruits/banana.js', {}); const anotherScriptTransformer = new ScriptTransformer({ ...config, - transform: [['^.+\\.js$', 'css-preprocessor']], + transform: [['\\.js$', 'css-preprocessor']], }); anotherScriptTransformer.transform('/fruits/banana.js', {}); @@ -746,7 +744,7 @@ describe('ScriptTransformer', () => { it('preload transformer when using `preloadTransformer`', () => { const scriptTransformer = new ScriptTransformer({ ...config, - transform: [['^.+\\.js$', 'test_preprocessor']], + transform: [['\\.js$', 'test_preprocessor']], }); expect(Array.from(scriptTransformer._transformCache.entries())).toEqual([]); diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index 128d65b0aedf..ea7df538be79 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -1,6 +1,6 @@ { "name": "@jest/types", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", diff --git a/packages/jest-types/src/Circus.ts b/packages/jest-types/src/Circus.ts index b4c94d57c3b6..c5f941efc11c 100644 --- a/packages/jest-types/src/Circus.ts +++ b/packages/jest-types/src/Circus.ts @@ -66,7 +66,7 @@ export type SyncEvent = asyncError: Error; name: 'add_test'; testName: TestName; - fn?: TestFn; + fn: TestFn; mode?: TestMode; timeout: number | undefined; } @@ -231,7 +231,7 @@ export type TestEntry = { type: 'test'; asyncError: Exception; // Used if the test failure contains no usable stack trace errors: Array; - fn?: TestFn; + fn: TestFn; invocations: number; mode: TestMode; name: TestName; diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index c492b08740df..ccd5e1dbd261 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -11,6 +11,8 @@ import type {ForegroundColor} from 'chalk'; type CoverageProvider = 'babel' | 'v8'; +type Timers = 'real' | 'fake' | 'modern' | 'legacy'; + export type Path = string; export type Glob = string; @@ -92,7 +94,7 @@ export type DefaultOptions = { testRunner: string; testSequencer: string; testURL: string; - timers: 'real' | 'fake'; + timers: Timers; transformIgnorePatterns: Array; useStderr: boolean; watch: boolean; @@ -206,7 +208,7 @@ export type InitialOptions = Partial<{ testSequencer: string; testURL: string; testTimeout: number; - timers: 'real' | 'fake'; + timers: Timers; transform: { [regex: string]: Path | TransformerConfig; }; @@ -362,7 +364,7 @@ export type ProjectConfig = { testRegex: Array; testRunner: string; testURL: string; - timers: 'real' | 'fake' | 'modern' | 'legacy'; + timers: Timers; transform: Array<[string, Path, Record]>; transformIgnorePatterns: Array; watchPathIgnorePatterns: Array; diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index 3af0068df096..e8412a2b12a7 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -1,6 +1,6 @@ { "name": "jest-util", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,7 +10,7 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "@types/node": "*", "chalk": "^4.0.0", "graceful-fs": "^4.2.4", diff --git a/packages/jest-validate/README.md b/packages/jest-validate/README.md index efe749a25838..ebf791d6075d 100644 --- a/packages/jest-validate/README.md +++ b/packages/jest-validate/README.md @@ -131,7 +131,7 @@ This will output: Example: { "transform": { - "^.+\\.js$": "/preprocessor.js" + "\\.js$": "/preprocessor.js" } } diff --git a/packages/jest-validate/package.json b/packages/jest-validate/package.json index 4e63fce4d0bf..a161a447ccf7 100644 --- a/packages/jest-validate/package.json +++ b/packages/jest-validate/package.json @@ -1,6 +1,6 @@ { "name": "jest-validate", - "version": "26.5.3", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -10,12 +10,12 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "camelcase": "^6.0.0", "chalk": "^4.0.0", "jest-get-type": "^26.3.0", "leven": "^3.1.0", - "pretty-format": "^26.5.2" + "pretty-format": "^26.6.0" }, "devDependencies": { "@types/yargs": "^15.0.3" diff --git a/packages/jest-validate/src/__tests__/fixtures/jestConfig.ts b/packages/jest-validate/src/__tests__/fixtures/jestConfig.ts index 8e1438a5e810..da7a4c201017 100644 --- a/packages/jest-validate/src/__tests__/fixtures/jestConfig.ts +++ b/packages/jest-validate/src/__tests__/fixtures/jestConfig.ts @@ -115,7 +115,7 @@ const validConfig = { testURL: 'http://localhost', timers: 'real', transform: { - '^.+\\.js$': '/preprocessor.js', + '\\.js$': '/preprocessor.js', }, transformIgnorePatterns: [NODE_MODULES_REGEXP], unmockedModulePathPatterns: ['mock'], diff --git a/packages/jest-watcher/package.json b/packages/jest-watcher/package.json index 6a2513969811..a0856c949d0b 100644 --- a/packages/jest-watcher/package.json +++ b/packages/jest-watcher/package.json @@ -1,16 +1,16 @@ { "name": "jest-watcher", "description": "Delightful JavaScript Testing.", - "version": "26.5.2", + "version": "26.6.0", "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { - "@jest/test-result": "^26.5.2", - "@jest/types": "^26.5.2", + "@jest/test-result": "^26.6.0", + "@jest/types": "^26.6.0", "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", - "jest-util": "^26.5.2", + "jest-util": "^26.6.0", "string-length": "^4.0.1" }, "repository": { diff --git a/packages/jest/package.json b/packages/jest/package.json index 5f91d0fa18ad..c255cde2e881 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -1,13 +1,13 @@ { "name": "jest", "description": "Delightful JavaScript Testing.", - "version": "26.5.3", + "version": "26.6.0", "main": "build/jest.js", "types": "build/jest.d.ts", "dependencies": { - "@jest/core": "^26.5.3", + "@jest/core": "^26.6.0", "import-local": "^3.0.2", - "jest-cli": "^26.5.3" + "jest-cli": "^26.6.0" }, "bin": "./bin/jest.js", "engines": { diff --git a/packages/pretty-format/package.json b/packages/pretty-format/package.json index 433ee9744536..09e441172401 100644 --- a/packages/pretty-format/package.json +++ b/packages/pretty-format/package.json @@ -1,6 +1,6 @@ { "name": "pretty-format", - "version": "26.5.2", + "version": "26.6.0", "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -12,7 +12,7 @@ "types": "build/index.d.ts", "author": "James Kyle ", "dependencies": { - "@jest/types": "^26.5.2", + "@jest/types": "^26.6.0", "ansi-regex": "^5.0.0", "ansi-styles": "^4.0.0", "react-is": "^16.12.0" @@ -22,7 +22,7 @@ "@types/react-is": "^16.7.1", "@types/react-test-renderer": "*", "immutable": "4.0.0-rc.9", - "jest-util": "^26.5.2", + "jest-util": "^26.6.0", "react": "*", "react-dom": "*", "react-test-renderer": "*" diff --git a/website/README.md b/website/README.md index ebfd2df11c40..b8a0c49f0724 100644 --- a/website/README.md +++ b/website/README.md @@ -10,6 +10,12 @@ yarn in the root directory. +Fetch `backers.json` file by running + +```bash +node fetchSupporters.js +``` + Then, run the server via ```bash diff --git a/website/pages/en/index.js b/website/pages/en/index.js index cbb880a7e3b9..8a307506915b 100755 --- a/website/pages/en/index.js +++ b/website/pages/en/index.js @@ -549,7 +549,7 @@ class Index extends React.Component {
{showcase} -

And many others

+

And many others

diff --git a/website/sidebars.json b/website/sidebars.json index 3c4cc29d4399..1cb762c601d6 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -39,7 +39,8 @@ "mock-function-api", "jest-object", "configuration", - "cli" + "cli", + "environment-variables" ] } } diff --git a/website/static/css/jest.css b/website/static/css/jest.css index 477e55ea67fc..976d0e8e25c4 100644 --- a/website/static/css/jest.css +++ b/website/static/css/jest.css @@ -152,8 +152,12 @@ padding-top: 10px; } -.logos { - align-items: center; +.logos > a { + margin-left: 0; +} + +.logos > p.others { + padding-top: 1.5rem !important; } @media only screen and (min-width: 736px) { diff --git a/website/versioned_docs/version-22.x/EnvironmentVariables.md b/website/versioned_docs/version-22.x/EnvironmentVariables.md new file mode 100644 index 000000000000..87ba1381f2e8 --- /dev/null +++ b/website/versioned_docs/version-22.x/EnvironmentVariables.md @@ -0,0 +1,15 @@ +--- +id: version-22.x-environment-variables +title: Environment Variables +original_id: environment-variables +--- + +Jest sets the following environment variables: + +### `NODE_ENV` + +Set to `'test'` if it's not already set to something else. + +### `JEST_WORKER_ID` + +Each worker process is assigned a unique id (index-based that starts with `1`). This is set to `1` for all tests when [`runInBand`](CLI.md#--runinband) is set to true. diff --git a/website/versioned_docs/version-26.0/ECMAScriptModules.md b/website/versioned_docs/version-26.0/ECMAScriptModules.md index b99d6400478b..21168fd3e11e 100644 --- a/website/versioned_docs/version-26.0/ECMAScriptModules.md +++ b/website/versioned_docs/version-26.0/ECMAScriptModules.md @@ -13,5 +13,5 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc. +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details diff --git a/website/versioned_sidebars/version-22.x-sidebars.json b/website/versioned_sidebars/version-22.x-sidebars.json index 5519b94c5267..630569168d5f 100644 --- a/website/versioned_sidebars/version-22.x-sidebars.json +++ b/website/versioned_sidebars/version-22.x-sidebars.json @@ -33,7 +33,8 @@ "version-22.x-mock-function-api", "version-22.x-jest-object", "version-22.x-configuration", - "version-22.x-cli" + "version-22.x-cli", + "version-22.x-environment-variables" ] } } diff --git a/website/versioned_sidebars/version-23.x-sidebars.json b/website/versioned_sidebars/version-23.x-sidebars.json index c681767309d2..de96dc37c761 100644 --- a/website/versioned_sidebars/version-23.x-sidebars.json +++ b/website/versioned_sidebars/version-23.x-sidebars.json @@ -36,7 +36,8 @@ "version-23.x-mock-function-api", "version-23.x-jest-object", "version-23.x-configuration", - "version-23.x-cli" + "version-23.x-cli", + "version-23.x-environment-variables" ] } } diff --git a/website/versioned_sidebars/version-24.x-sidebars.json b/website/versioned_sidebars/version-24.x-sidebars.json index b9317eec8d8d..70a7968ade02 100644 --- a/website/versioned_sidebars/version-24.x-sidebars.json +++ b/website/versioned_sidebars/version-24.x-sidebars.json @@ -38,7 +38,8 @@ "version-24.x-mock-function-api", "version-24.x-jest-object", "version-24.x-configuration", - "version-24.x-cli" + "version-24.x-cli", + "version-24.x-environment-variables" ] } } diff --git a/website/versioned_sidebars/version-26.0-sidebars.json b/website/versioned_sidebars/version-26.0-sidebars.json index c69d3ac005d8..d791b145a933 100644 --- a/website/versioned_sidebars/version-26.0-sidebars.json +++ b/website/versioned_sidebars/version-26.0-sidebars.json @@ -39,7 +39,8 @@ "version-26.0-mock-function-api", "version-26.0-jest-object", "version-26.0-configuration", - "version-26.0-cli" + "version-26.0-cli", + "version-26.0-environment-variables" ] } } diff --git a/yarn.lock b/yarn.lock index be5fd2fffb42..e5177dc89236 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1767,14 +1767,14 @@ __metadata: languageName: node linkType: hard -"@jest/core@^26.5.2, @jest/core@workspace:packages/jest-core": +"@jest/core@^26.5.3, @jest/core@workspace:packages/jest-core": version: 0.0.0-use.local resolution: "@jest/core@workspace:packages/jest-core" dependencies: "@jest/console": ^26.5.2 - "@jest/reporters": ^26.5.2 + "@jest/reporters": ^26.5.3 "@jest/test-result": ^26.5.2 - "@jest/test-sequencer": ^26.5.2 + "@jest/test-sequencer": ^26.5.3 "@jest/transform": ^26.5.2 "@jest/types": ^26.5.2 "@types/exit": ^0.1.30 @@ -1787,18 +1787,18 @@ __metadata: exit: ^0.1.2 graceful-fs: ^4.2.4 jest-changed-files: ^26.5.2 - jest-config: ^26.5.2 + jest-config: ^26.5.3 jest-haste-map: ^26.5.2 jest-message-util: ^26.5.2 jest-regex-util: ^26.0.0 jest-resolve: ^26.5.2 - jest-resolve-dependencies: ^26.5.2 - jest-runner: ^26.5.2 - jest-runtime: ^26.5.2 - jest-snapshot: ^26.5.2 + jest-resolve-dependencies: ^26.5.3 + jest-runner: ^26.5.3 + jest-runtime: ^26.5.3 + jest-snapshot: ^26.5.3 jest-snapshot-serializer-raw: ^1.1.0 jest-util: ^26.5.2 - jest-validate: ^26.5.2 + jest-validate: ^26.5.3 jest-watcher: ^26.5.2 micromatch: ^4.0.2 p-each-series: ^2.1.0 @@ -1852,17 +1852,17 @@ __metadata: languageName: node linkType: hard -"@jest/globals@^26.5.2, @jest/globals@workspace:packages/jest-globals": +"@jest/globals@^26.5.3, @jest/globals@workspace:packages/jest-globals": version: 0.0.0-use.local resolution: "@jest/globals@workspace:packages/jest-globals" dependencies: "@jest/environment": ^26.5.2 "@jest/types": ^26.5.2 - expect: ^26.5.2 + expect: ^26.5.3 languageName: unknown linkType: soft -"@jest/reporters@^26.5.2, @jest/reporters@workspace:packages/jest-reporters": +"@jest/reporters@^26.5.3, @jest/reporters@workspace:packages/jest-reporters": version: 0.0.0-use.local resolution: "@jest/reporters@workspace:packages/jest-reporters" dependencies: @@ -1952,7 +1952,7 @@ __metadata: languageName: node linkType: hard -"@jest/test-sequencer@^26.5.2, @jest/test-sequencer@workspace:packages/jest-test-sequencer": +"@jest/test-sequencer@^26.5.3, @jest/test-sequencer@workspace:packages/jest-test-sequencer": version: 0.0.0-use.local resolution: "@jest/test-sequencer@workspace:packages/jest-test-sequencer" dependencies: @@ -1960,8 +1960,8 @@ __metadata: "@types/graceful-fs": ^4.1.3 graceful-fs: ^4.2.4 jest-haste-map: ^26.5.2 - jest-runner: ^26.5.2 - jest-runtime: ^26.5.2 + jest-runner: ^26.5.3 + jest-runtime: ^26.5.3 languageName: unknown linkType: soft @@ -4367,6 +4367,13 @@ __metadata: languageName: node linkType: hard +"arg@npm:^4.1.0": + version: 4.1.3 + resolution: "arg@npm:4.1.3" + checksum: 81b3b40b1529c4fbf75b12f7c3e6fb2dcce9e78072063babc169de9b4f40777788f3d2b04380f659ef676a756e03ccfbfe78adf4477353bda906295fa69dab89 + languageName: node + linkType: hard + "argparse@npm:^1.0.10, argparse@npm:^1.0.7": version: 1.0.10 resolution: "argparse@npm:1.0.10" @@ -8483,7 +8490,7 @@ __metadata: languageName: node linkType: hard -"expect@^26.5.2, expect@workspace:packages/expect": +"expect@^26.5.3, expect@workspace:packages/expect": version: 0.0.0-use.local resolution: "expect@workspace:packages/expect" dependencies: @@ -11361,7 +11368,7 @@ fsevents@^1.2.7: languageName: unknown linkType: soft -"jest-circus@^26.5.2, jest-circus@workspace:packages/jest-circus": +"jest-circus@^26.5.3, jest-circus@workspace:packages/jest-circus": version: 0.0.0-use.local resolution: "jest-circus@workspace:packages/jest-circus" dependencies: @@ -11382,15 +11389,15 @@ fsevents@^1.2.7: co: ^4.6.0 dedent: ^0.7.0 execa: ^4.0.0 - expect: ^26.5.2 + expect: ^26.5.3 graceful-fs: ^4.2.4 is-generator-fn: ^2.0.0 jest-each: ^26.5.2 jest-matcher-utils: ^26.5.2 jest-message-util: ^26.5.2 - jest-runner: ^26.5.2 - jest-runtime: ^26.5.2 - jest-snapshot: ^26.5.2 + jest-runner: ^26.5.3 + jest-runtime: ^26.5.3 + jest-snapshot: ^26.5.3 jest-util: ^26.5.2 pretty-format: ^26.5.2 stack-utils: ^2.0.2 @@ -11398,11 +11405,11 @@ fsevents@^1.2.7: languageName: unknown linkType: soft -"jest-cli@^26.5.2, jest-cli@workspace:packages/jest-cli": +"jest-cli@^26.5.3, jest-cli@workspace:packages/jest-cli": version: 0.0.0-use.local resolution: "jest-cli@workspace:packages/jest-cli" dependencies: - "@jest/core": ^26.5.2 + "@jest/core": ^26.5.3 "@jest/test-result": ^26.5.2 "@jest/test-utils": ^26.5.0 "@jest/types": ^26.5.2 @@ -11416,9 +11423,9 @@ fsevents@^1.2.7: graceful-fs: ^4.2.4 import-local: ^3.0.2 is-ci: ^2.0.0 - jest-config: ^26.5.2 + jest-config: ^26.5.3 jest-util: ^26.5.2 - jest-validate: ^26.5.2 + jest-validate: ^26.5.3 prompts: ^2.0.1 yargs: ^15.4.1 bin: @@ -11426,12 +11433,12 @@ fsevents@^1.2.7: languageName: unknown linkType: soft -"jest-config@^26.5.2, jest-config@workspace:packages/jest-config": +"jest-config@^26.5.3, jest-config@workspace:packages/jest-config": version: 0.0.0-use.local resolution: "jest-config@workspace:packages/jest-config" dependencies: "@babel/core": ^7.1.0 - "@jest/test-sequencer": ^26.5.2 + "@jest/test-sequencer": ^26.5.3 "@jest/types": ^26.5.2 "@types/babel__core": ^7.0.4 "@types/glob": ^7.1.1 @@ -11445,13 +11452,20 @@ fsevents@^1.2.7: jest-environment-jsdom: ^26.5.2 jest-environment-node: ^26.5.2 jest-get-type: ^26.3.0 - jest-jasmine2: ^26.5.2 + jest-jasmine2: ^26.5.3 jest-regex-util: ^26.0.0 jest-resolve: ^26.5.2 jest-util: ^26.5.2 - jest-validate: ^26.5.2 + jest-validate: ^26.5.3 micromatch: ^4.0.2 pretty-format: ^26.5.2 + ts-node: ^9.0.0 + typescript: ^4.0.3 + peerDependencies: + ts-node: ">=9.0.0" + peerDependenciesMeta: + ts-node: + optional: true languageName: unknown linkType: soft @@ -11583,7 +11597,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"jest-jasmine2@^26.5.2, jest-jasmine2@workspace:packages/jest-jasmine2": +"jest-jasmine2@^26.5.3, jest-jasmine2@workspace:packages/jest-jasmine2": version: 0.0.0-use.local resolution: "jest-jasmine2@workspace:packages/jest-jasmine2" dependencies: @@ -11597,13 +11611,13 @@ fsevents@^1.2.7: "@types/node": "*" chalk: ^4.0.0 co: ^4.6.0 - expect: ^26.5.2 + expect: ^26.5.3 is-generator-fn: ^2.0.0 jest-each: ^26.5.2 jest-matcher-utils: ^26.5.2 jest-message-util: ^26.5.2 - jest-runtime: ^26.5.2 - jest-snapshot: ^26.5.2 + jest-runtime: ^26.5.3 + jest-snapshot: ^26.5.3 jest-util: ^26.5.2 pretty-format: ^26.5.2 throat: ^5.0.0 @@ -11734,9 +11748,9 @@ fsevents@^1.2.7: "@jest/transform": ^26.5.2 "@jest/types": ^26.5.2 "@types/yargs": ^15.0.0 - jest-config: ^26.5.2 - jest-runtime: ^26.5.2 - jest-validate: ^26.5.2 + jest-config: ^26.5.3 + jest-runtime: ^26.5.3 + jest-validate: ^26.5.3 repl: ^0.1.3 yargs: ^15.4.1 bin: @@ -11744,7 +11758,7 @@ fsevents@^1.2.7: languageName: unknown linkType: soft -"jest-resolve-dependencies@^26.5.2, jest-resolve-dependencies@workspace:packages/jest-resolve-dependencies": +"jest-resolve-dependencies@^26.5.3, jest-resolve-dependencies@workspace:packages/jest-resolve-dependencies": version: 0.0.0-use.local resolution: "jest-resolve-dependencies@workspace:packages/jest-resolve-dependencies" dependencies: @@ -11752,8 +11766,8 @@ fsevents@^1.2.7: jest-haste-map: ^26.5.2 jest-regex-util: ^26.0.0 jest-resolve: ^26.5.2 - jest-runtime: ^26.5.2 - jest-snapshot: ^26.5.2 + jest-runtime: ^26.5.3 + jest-snapshot: ^26.5.3 languageName: unknown linkType: soft @@ -11786,7 +11800,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"jest-runner@^26.5.2, jest-runner@workspace:packages/jest-runner": +"jest-runner@^26.5.3, jest-runner@workspace:packages/jest-runner": version: 0.0.0-use.local resolution: "jest-runner@workspace:packages/jest-runner" dependencies: @@ -11802,14 +11816,14 @@ fsevents@^1.2.7: emittery: ^0.7.1 exit: ^0.1.2 graceful-fs: ^4.2.4 - jest-circus: ^26.5.2 - jest-config: ^26.5.2 + jest-circus: ^26.5.3 + jest-config: ^26.5.3 jest-docblock: ^26.0.0 jest-haste-map: ^26.5.2 jest-leak-detector: ^26.5.2 jest-message-util: ^26.5.2 jest-resolve: ^26.5.2 - jest-runtime: ^26.5.2 + jest-runtime: ^26.5.3 jest-util: ^26.5.2 jest-worker: ^26.5.0 source-map-support: ^0.5.6 @@ -11817,14 +11831,14 @@ fsevents@^1.2.7: languageName: unknown linkType: soft -"jest-runtime@^26.5.2, jest-runtime@workspace:packages/jest-runtime": +"jest-runtime@^26.5.3, jest-runtime@workspace:packages/jest-runtime": version: 0.0.0-use.local resolution: "jest-runtime@workspace:packages/jest-runtime" dependencies: "@jest/console": ^26.5.2 "@jest/environment": ^26.5.2 "@jest/fake-timers": ^26.5.2 - "@jest/globals": ^26.5.2 + "@jest/globals": ^26.5.3 "@jest/source-map": ^26.5.0 "@jest/test-result": ^26.5.2 "@jest/test-utils": ^26.5.0 @@ -11841,17 +11855,17 @@ fsevents@^1.2.7: exit: ^0.1.2 glob: ^7.1.3 graceful-fs: ^4.2.4 - jest-config: ^26.5.2 + jest-config: ^26.5.3 jest-environment-node: ^26.5.2 jest-haste-map: ^26.5.2 jest-message-util: ^26.5.2 jest-mock: ^26.5.2 jest-regex-util: ^26.0.0 jest-resolve: ^26.5.2 - jest-snapshot: ^26.5.2 + jest-snapshot: ^26.5.3 jest-snapshot-serializer-raw: ^1.1.0 jest-util: ^26.5.2 - jest-validate: ^26.5.2 + jest-validate: ^26.5.3 slash: ^3.0.0 strip-bom: ^4.0.0 yargs: ^15.4.1 @@ -11894,7 +11908,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"jest-snapshot@^26.5.2, jest-snapshot@workspace:packages/jest-snapshot": +"jest-snapshot@^26.5.3, jest-snapshot@workspace:packages/jest-snapshot": version: 0.0.0-use.local resolution: "jest-snapshot@workspace:packages/jest-snapshot" dependencies: @@ -11909,7 +11923,7 @@ fsevents@^1.2.7: ansi-regex: ^5.0.0 ansi-styles: ^4.2.0 chalk: ^4.0.0 - expect: ^26.5.2 + expect: ^26.5.3 graceful-fs: ^4.2.4 jest-diff: ^26.5.2 jest-get-type: ^26.3.0 @@ -11960,7 +11974,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"jest-validate@^26.5.2, jest-validate@workspace:packages/jest-validate": +"jest-validate@^26.5.3, jest-validate@workspace:packages/jest-validate": version: 0.0.0-use.local resolution: "jest-validate@workspace:packages/jest-validate" dependencies: @@ -12077,9 +12091,9 @@ fsevents@^1.2.7: version: 0.0.0-use.local resolution: "jest@workspace:packages/jest" dependencies: - "@jest/core": ^26.5.2 + "@jest/core": ^26.5.3 import-local: ^3.0.2 - jest-cli: ^26.5.2 + jest-cli: ^26.5.3 bin: jest: ./bin/jest.js languageName: unknown @@ -13035,6 +13049,13 @@ fsevents@^1.2.7: languageName: node linkType: hard +"make-error@npm:^1.1.1": + version: 1.3.6 + resolution: "make-error@npm:1.3.6" + checksum: 2c780bab8409b865e8ee86697c599a2bf2765ec64d21eb67ccda27050e039f983feacad05a0d43aba3c966ea03d305d2612e94fec45474bcbc61181f57c5bb88 + languageName: node + linkType: hard + "make-fetch-happen@npm:^5.0.0": version: 5.0.2 resolution: "make-fetch-happen@npm:5.0.2" @@ -17097,6 +17118,7 @@ fsevents@^1.2.7: strip-ansi: ^6.0.0 tempy: ^0.6.0 throat: ^5.0.0 + ts-node: ^9.0.0 type-fest: ^0.16.0 typescript: ^4.0.2 which: ^2.0.1 @@ -17732,7 +17754,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"source-map-support@npm:^0.5.16": +"source-map-support@npm:^0.5.16, source-map-support@npm:^0.5.17": version: 0.5.19 resolution: "source-map-support@npm:0.5.19" dependencies: @@ -18907,6 +18929,26 @@ fsevents@^1.2.7: languageName: node linkType: hard +"ts-node@npm:^9.0.0": + version: 9.0.0 + resolution: "ts-node@npm:9.0.0" + dependencies: + arg: ^4.1.0 + diff: ^4.0.1 + make-error: ^1.1.1 + source-map-support: ^0.5.17 + yn: 3.1.1 + peerDependencies: + typescript: ">=2.7" + bin: + ts-node: dist/bin.js + ts-node-script: dist/bin-script.js + ts-node-transpile-only: dist/bin-transpile.js + ts-script: dist/bin-script-deprecated.js + checksum: 49d2ab087fc4b93f0a292e426ea6d242a80d1a4809ac008758bb0170aea1a85cd4182792c1d70889285fe5328cd8bd1ffb1e5108d1c4f31c39dbe9151ea4cabe + languageName: node + linkType: hard + "tsconfig-paths@npm:^3.9.0": version: 3.9.0 resolution: "tsconfig-paths@npm:3.9.0" @@ -19060,7 +19102,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"typescript@*, typescript@^4.0.2": +"typescript@*, typescript@^4.0.2, typescript@^4.0.3": version: 4.0.3 resolution: "typescript@npm:4.0.3" bin: @@ -19070,7 +19112,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"typescript@patch:typescript@*#builtin, typescript@patch:typescript@^4.0.2#builtin": +"typescript@patch:typescript@*#builtin, typescript@patch:typescript@^4.0.2#builtin, typescript@patch:typescript@^4.0.3#builtin": version: 4.0.3 resolution: "typescript@patch:typescript@npm%3A4.0.3#builtin::version=4.0.3&hash=5bf698" bin: @@ -20169,6 +20211,13 @@ fsevents@^1.2.7: languageName: node linkType: hard +"yn@npm:3.1.1": + version: 3.1.1 + resolution: "yn@npm:3.1.1" + checksum: bff63b80568d80c711670935427494dde47cdf97e8b04196b140ce0af519c81c5ee857eddad0caa8b422dd65aea0157bbfaacbb1546bebba623f0f383d5d9ae5 + languageName: node + linkType: hard + "zone.js@npm:~0.10.2": version: 0.10.3 resolution: "zone.js@npm:0.10.3"