Skip to content

Commit

Permalink
Merge branch 'main' into add-node-performance-global
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSiefke authored Dec 29, 2021
2 parents 2c66cdb + 5706d71 commit 2396f00
Show file tree
Hide file tree
Showing 202 changed files with 14,152 additions and 3,829 deletions.
9 changes: 6 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ module.exports = {
},
},
{
files: ['test-types/*.test.ts', '*.md'],
files: ['**/__typechecks__/**', '*.md'],
rules: {
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
Expand Down Expand Up @@ -301,9 +301,9 @@ module.exports = {
'error',
{
devDependencies: [
'/test-types/**',
'**/__tests__/**',
'**/__mocks__/**',
'**/__tests__/**',
'**/__typechecks__/**',
'**/?(*.)(spec|test).js?(x)',
'scripts/**',
'babel.config.js',
Expand Down Expand Up @@ -485,5 +485,8 @@ module.exports = {
'import/internal-regex': new RegExp(
internalPackages.map(pkg => `^${pkg}$`).join('|'),
).source,
'import/resolver': {
typescript: {},
},
},
};
66 changes: 64 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,81 @@

### Features

### Fixes

- `[@jest/transform]` Update dependency package `pirates` to 4.0.4 ([#12136](https://github.com/facebook/jest/pull/12136))
- `[jest-environment-node]` Add `AbortSignal` ([#12157](https://github.com/facebook/jest/pull/12157))
- `[jest-environment-node]` Add Missing node global `performance` ([#12002](https://github.com/facebook/jest/pull/12002))

### Chore & Maintenance

### Performance

- `jest-config` perf: only register ts-node once when loading TS config files ([#12160](https://github.com/facebook/jest/pull/12160))

## 27.4.5

### Fixes

- `[jest-worker]` Stop explicitly passing `process.env` ([#12141](https://github.com/facebook/jest/pull/12141))

## 27.4.4

### Fixes

- `[babel-jest]` Add `process.version` chunk to the cache key ([#12122](https://github.com/facebook/jest/pull/12122))
- `[jest-environment]` Add `mocked` to `jest` object ([#12133](https://github.com/facebook/jest/pull/12133))
- `[jest-worker]` Stop explicitly passing `execArgv` ([#12128](https://github.com/facebook/jest/pull/12128))

### Chore & Maintenance

- `[website]` Fix the card front that looks overlapping part of the card back

## 27.4.3

### Fixes

- `[jest-environment-jsdom]` Remove `@types/jsdom` dependency (and make its `dom` property `private`) ([#12107](https://github.com/facebook/jest/pull/12107))

## 27.4.2

### Fixes

- `[jest-worker]` Add additional `execArgv` to filter ([#12103](https://github.com/facebook/jest/pull/12103))

## 27.4.1

### Fixes

- `[jest-worker]` Filter `execArgv` correctly ([#12097](https://github.com/facebook/jest/pull/12097))

## 27.4.0

### Features

- `[expect]` Enhancing the `toHaveProperty` matcher to support array selection ([#12092](https://github.com/facebook/jest/pull/12092))
- `[jest-core]` Add support for `testResultsProcessor` written in ESM ([#12006](https://github.com/facebook/jest/pull/12006))
- `[jest-diff, pretty-format]` Add `compareKeys` option for custom sorting of object keys ([#11992](https://github.com/facebook/jest/pull/11992))
- `[jest-mock]` Add `ts-jest` mock util functions ([#12089](https://github.com/facebook/jest/pull/12089))

### Fixes

- `[expect]` Allow again `expect.Matchers` generic with single value ([#11986](https://github.com/facebook/jest/pull/11986))
- `[jest-circus, jest-jasmine2]` Avoid false concurrent test failures due to unhandled promise rejections ([#11987](https://github.com/facebook/jest/pull/11987))
- `[jest-config]` Add missing `slash` dependency to `package.json` ([#12080](https://github.com/facebook/jest/pull/12080))
- `[jest-core]` Incorrect detection of open ZLIB handles ([#12022](https://github.com/facebook/jest/pull/12022))
- `[jest-diff]` Break dependency cycle ([#10818](https://github.com/facebook/jest/pull/10818))
- `[jest-environment-jsdom]` Add `@types/jsdom` dependency ([#11999](https://github.com/facebook/jest/pull/11999))
- `[jest-environment-node]` Add Missing node global `performance` ([#12002](https://github.com/facebook/jest/pull/12002))
- `[jest-environment-jsdom]` Do not reset the global.document too early on teardown ([#11871](https://github.com/facebook/jest/pull/11871))
- `[jest-transform]` Improve error and warning messages ([#11998](https://github.com/facebook/jest/pull/11998))
- `[jest-worker]` Pass `execArgv` correctly to `worker_threads` worker ([#12069](https://github.com/facebook/jest/pull/12069))

### Chore & Maintenance

### Performance
- `[docs]` CLI options alphabetized ([#11586](https://github.com/facebook/jest/pull/11586))
- `[jest-runner]` Add info regarding timers to forcedExit message([#12083](https://github.com/facebook/jest/pull/12083))
- `[*]` Replaced `substr` method with `substring` ([#12066](https://github.com/facebook/jest/pull/12066))
- `[*]` Add `types` entry to all export maps ([#12073](https://github.com/facebook/jest/pull/12073))

## 27.3.1

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _Before_ submitting a pull request, please make sure the following is done…
python --version
```

1. Make sure you have a compatible version of `node` installed (As of April 14th 2021, `v14.x` is recommended).
1. Make sure you have a compatible version of `node` installed (As of October 29th 2021, `v16.x` is recommended).

```sh
node -v
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="http://badge.fury.io/js/jest"><img src="https://badge.fury.io/js/jest.svg" alt="npm version"></a>
<a href="https://badge.fury.io/js/jest"><img src="https://badge.fury.io/js/jest.svg" alt="npm version"></a>
<a href="https://github.com/facebook/jest/blob/main/LICENSE">
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Jest is released under the MIT license." />
</a>
Expand Down
44 changes: 28 additions & 16 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ When this option is provided, Jest will assume it is running in a CI environment

Deletes the Jest cache directory and then exits without running tests. Will delete `cacheDirectory` if the option is passed, or Jest's default cache directory. The default cache directory can be found by calling `jest --showConfig`. _Note: clearing the cache will reduce performance._

### `--clearMocks`

Automatically clear mock calls, instances and results before every test. Equivalent to calling [`jest.clearAllMocks()`](JestObjectAPI.md#jestclearallmocks) before each test. This does not remove any mock implementation that may have been provided.

### `--collectCoverageFrom=<glob>`

A glob pattern relative to `rootDir` matching the files that coverage info needs to be collected from.
Expand Down Expand Up @@ -220,10 +224,6 @@ _Note: This option is only supported using the default `jest-circus` test runner

Prints the test results in JSON. This mode will send all other test output and user messages to stderr.

### `--outputFile=<filename>`

Write test results to a file when the `--json` option is also specified. The returned JSON structure is documented in [testResultsProcessor](Configuration.md#testresultsprocessor-string).

### `--lastCommit`

Run all tests affected by file changes in the last commit made. Behaves similarly to `--onlyChanged`.
Expand Down Expand Up @@ -258,6 +258,10 @@ Activates notifications for test results. Good for when you don't want your cons

Alias: `-o`. Attempts to identify which tests to run based on which files have changed in the current repository. Only works if you're running tests in a git/hg repository at the moment and requires a static dependency graph (ie. no dynamic requires).

### `--outputFile=<filename>`

Write test results to a file when the `--json` option is also specified. The returned JSON structure is documented in [testResultsProcessor](Configuration.md#testresultsprocessor-string).

### `--passWithNoTests`

Allows the test suite to pass when no files are found.
Expand All @@ -272,6 +276,14 @@ Run tests with specified reporters. [Reporter options](configuration#reporters-a

`jest --reporters="default" --reporters="jest-junit"`

### `--resetMocks`

Automatically reset mock state before every test. Equivalent to calling [`jest.resetAllMocks()`](JestObjectAPI.md#jestresetallmocks) before each test. This will lead to any mocks having their fake implementations removed but does not restore their initial implementation.

### `--restoreMocks`

Automatically restore mock state and implementation before every test. Equivalent to calling [`jest.restoreAllMocks()`](JestObjectAPI.md#jestrestoreallmocks) before each test. This will lead to any mocks having their fake implementations removed and restores their initial implementation.

### `--roots`

A list of paths to directories that Jest should use to search for files in.
Expand All @@ -280,16 +292,16 @@ A list of paths to directories that Jest should use to search for files in.

Alias: `-i`. Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests. This can be useful for debugging.

### `--selectProjects <project1> ... <projectN>`

Run only the tests of the specified projects. Jest uses the attribute `displayName` in the configuration to identify each project. If you use this option, you should provide a `displayName` to all your projects.

### `--runTestsByPath`

Run only the tests that were specified with their exact paths.

_Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_

### `--selectProjects <project1> ... <projectN>`

Run only the tests of the specified projects. Jest uses the attribute `displayName` in the configuration to identify each project. If you use this option, you should provide a `displayName` to all your projects.

### `--setupFilesAfterEnv <path1> ... <pathN>`

A list of paths to modules that run some code to configure or to set up the testing framework before each test. Beware that files imported by the setup scripts will not be mocked during testing.
Expand All @@ -306,12 +318,6 @@ Prevent tests from printing messages through the console.

A JSON string with options that will be passed to the `testEnvironment`. The relevant options depend on the environment.

### `--testNamePattern=<regex>`

Alias: `-t`. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like `"GET /api/posts with auth"`, then you can use `jest -t=auth`.

_Note: The regex is matched against the full name, which is a combination of the test name and all its surrounding describe blocks._

### `--testLocationInResults`

Adds a `location` field to test results. Useful if you want to report the location of a test in a reporter.
Expand All @@ -325,16 +331,22 @@ Note that `column` is 0-indexed while `line` is not.
}
```

### `--testPathPattern=<regex>`
### `--testNamePattern=<regex>`

A regexp pattern string that is matched against all tests paths before executing the test. On Windows, you will need to use `/` as a path separator or escape `\` as `\\`.
Alias: -t. Run only tests with a name that matches the regex. For example, suppose you want to run only tests related to authorization which will have names like "GET /api/posts with auth", then you can use jest -t=auth.

Note: The regex is matched against the full name, which is a combination of the test name and all its surrounding describe blocks.

### `--testPathIgnorePatterns=<regex>|[array]`

A single or array of regexp pattern strings that are tested against all tests paths before executing the test. Contrary to `--testPathPattern`, it will only run those tests with a path that does not match with the provided regexp expressions.

To pass as an array use escaped parentheses and space delimited regexps such as `\(/node_modules/ /tests/e2e/\)`. Alternatively, you can omit parentheses by combining regexps into a single regexp like `/node_modules/|/tests/e2e/`. These two examples are equivalent.

### `--testPathPattern=<regex>`

A regexp pattern string that is matched against all tests paths before executing the test. On Windows, you will need to use `/` as a path separator or escape `\` as `\\`.

### `--testRunner=<path>`

Lets you specify a custom test runner.
Expand Down
8 changes: 4 additions & 4 deletions docs/CodeTransformation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ If you override the `transform` configuration option `babel-jest` will no longer

## Writing custom transformers

You can write you own transformer. The API of a transformer is as follows:
You can write your own transformer. The API of a transformer is as follows:

```ts
interface SyncTransformer<OptionType = unknown> {
/**
* Indicates if the transformer is capabale of instrumenting the code for code coverage.
* Indicates if the transformer is capable of instrumenting the code for code coverage.
*
* If V8 coverage is _not_ active, and this is `true`, Jest will assume the code is instrumented.
* If V8 coverage is _not_ active, and this is `false`. Jest will instrument the code returned by this transformer using Babel.
Expand Down Expand Up @@ -59,7 +59,7 @@ interface SyncTransformer<OptionType = unknown> {

interface AsyncTransformer<OptionType = unknown> {
/**
* Indicates if the transformer is capabale of instrumenting the code for code coverage.
* Indicates if the transformer is capable of instrumenting the code for code coverage.
*
* If V8 coverage is _not_ active, and this is `true`, Jest will assume the code is instrumented.
* If V8 coverage is _not_ active, and this is `false`. Jest will instrument the code returned by this transformer using Babel.
Expand Down Expand Up @@ -120,7 +120,7 @@ type TransformedSource =
| {code: string; map?: RawSourceMap | string | null}
| string;

// Config.ProjectConfig can be seen in in code [here](https://github.com/facebook/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L323)
// Config.ProjectConfig can be seen in code [here](https://github.com/facebook/jest/blob/v26.6.3/packages/jest-types/src/Config.ts#L323)
// RawSourceMap comes from [`source-map`](https://github.com/mozilla/source-map/blob/0.6.1/source-map.d.ts#L6-L12)
```

Expand Down
Loading

0 comments on commit 2396f00

Please sign in to comment.