Skip to content

Commit 2bca3b6

Browse files
committed
Merge branch 'master' into babel-7
2 parents 1d976ae + 993bc5c commit 2bca3b6

File tree

331 files changed

+3275
-1170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+3275
-1170
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- restore-cache: *restore-cache
2727
- run: yarn --no-progress
2828
- save-cache: *save-cache
29-
- run: yarn lint --format junit -o reports/junit/js-lint-results.xml && yarn typecheck && yarn lint-es5-build --format junit -o reports/junit/js-es5-lint-results.xml && yarn lint:md:ci
29+
- run: yarn lint --format junit -o reports/junit/js-lint-results.xml && yarn typecheck && yarn lint-es5-build --format junit -o reports/junit/js-es5-lint-results.xml && yarn lint:md:ci && yarn check-copyright-headers
3030
- store_test_results:
3131
path: reports/junit
3232

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ untyped-import
1818
untyped-type-import
1919

2020
[version]
21-
^0.80.0
21+
^0.85.0

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fixtures/failing-jsons/
2+
packages/jest-config/src/__tests__/jest-preset.json
3+
packages/pretty-format/perf/world.geo.json

CHANGELOG.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Features
44

5+
- `[jest-validate]` Add support for comments in `package.json` using a `"//"` key [#7295](https://github.com/facebook/jest/pull/7295))
6+
- `[jest-config]` Add shorthand for watch plugins and runners ([#7213](https://github.com/facebook/jest/pull/7213))
57
- `[jest-config]` [**BREAKING**] Deprecate `setupTestFrameworkScriptFile` in favor of new `setupFilesAfterEnv` ([#7119](https://github.com/facebook/jest/pull/7119))
68
- `[jest-jasmine2/jest-circus/jest-cli]` Add test.todo ([#6996](https://github.com/facebook/jest/pull/6996))
79
- `[pretty-format]` Option to not escape strings in diff messages ([#5661](https://github.com/facebook/jest/pull/5661))
@@ -24,11 +26,18 @@
2426
- `[jest-config]` Accept an array as as well as a string for `testRegex`([#7209]https://github.com/facebook/jest/pull/7209))
2527
- `[babel-preset-jest]` [**BREAKING**] Export a function instead of an object for Babel 7 compatibility ([#7203](https://github.com/facebook/jest/pull/7203))
2628
- `[expect]` Check constructor equality in .toStrictEqual() ([#7005](https://github.com/facebook/jest/pull/7005))
29+
- `[jest-util]` Add `jest.getTimerCount()` to get the count of scheduled fake timers ([#7285](https://github.com/facebook/jest/pull/7285))
30+
- `[jest-config]` Add `dependencyExtractor` option to use a custom module to extract dependencies from files ([#7313](https://github.com/facebook/jest/pull/7313), [#7349](https://github.com/facebook/jest/pull/7349), [#7350](https://github.com/facebook/jest/pull/7350))
31+
- `[jest-haste-map]` [**BREAKING**] Expose relative paths when getting the file iterator ([#7321](https://github.com/facebook/jest/pull/7321))
32+
- `[jest-haste-map]` Accept a `getCacheKey` method in `hasteImplModulePath` modules to reset the cache when the logic changes ([#7350](https://github.com/facebook/jest/pull/7350))
33+
- `[jest-config]` Add `haste.computeSha1` option to compute the sha-1 of the files in the haste map ([#7345](https://github.com/facebook/jest/pull/7345))
2734

2835
### Fixes
2936

37+
- `[expect]` Standardize file naming in `expect` ([#7306](https://github.com/facebook/jest/pull/7306))
38+
- `[jest-each]` Add empty array validation check ([#7249](https://github.com/facebook/jest/pull/7249))
3039
- `[jest-cli]` Interrupt tests if interactive watch plugin key is pressed ([#7222](https://github.com/facebook/jest/pull/7222))
31-
- `[jest-cli]` Fix coverage summary reporting ([#7058](https://github.com/facebook/jest/pull/7058))
40+
- `[jest-cli]` [**BREAKING**] Do not use `text-summary` coverage reporter by default if other reporters are configured ([#7058](https://github.com/facebook/jest/pull/7058))
3241
- `[jest-each]` Add each array validation check ([#7033](https://github.com/facebook/jest/pull/7033))
3342
- `[jest-haste-map]` Do not visit again files with the same sha-1 ([#6990](https://github.com/facebook/jest/pull/6990))
3443
- `[jest-jasmine2]` Fix memory leak in Error objects hold by the framework ([#6965](https://github.com/facebook/jest/pull/6965))
@@ -54,9 +63,22 @@
5463
- `[jest-changed-files]` Return correctly the changed files when using `lastCommit=true` on Mercurial repositories ([#7228](https://github.com/facebook/jest/pull/7228))
5564
- `[babel-jest]` Cache includes babel environment variables ([#7239](https://github.com/facebook/jest/pull/7239))
5665
- `[jest-config]` Use strings instead of `RegExp` instances in normalized configuration ([#7251](https://github.com/facebook/jest/pull/7251))
66+
- `[jest-circus]` Make sure to display real duration even if time is mocked ([#7264](https://github.com/facebook/jest/pull/7264))
67+
- `[expect]` Improves the failing message for `toStrictEqual` matcher. ([#7224](https://github.com/facebook/jest/pull/7224))
68+
- `[jest-mock]` [**BREAKING**] Fix bugs with mock/spy result tracking of recursive functions ([#6381](https://github.com/facebook/jest/pull/6381))
69+
- `[jest-resolve]` Fix not being able to resolve path to mapped file with custom platform ([#7312](https://github.com/facebook/jest/pull/7312))
70+
- `[jest-message-util]` Improve parsing of error messages for unusually formatted stack traces ([#7319](https://github.com/facebook/jest/pull/7319))
71+
- `[jest-runtime]` Ensure error message text is not lost on errors with code frames ([#7319](https://github.com/facebook/jest/pull/7319))
72+
- `[jest-haste-map]` Fix to resolve path that is start with words same as rootDir ([#7324](https://github.com/facebook/jest/pull/7324))
73+
- `[expect]` Fix toMatchObject matcher when used with `Object.create(null)` ([#7334](https://github.com/facebook/jest/pull/7334))
74+
- `[jest-haste-map]` [**BREAKING**] Recover files correctly after haste name collisions are fixed ([#7329](https://github.com/facebook/jest/pull/7329))
75+
- `[jest-haste-map]` Remove legacy condition for duplicate module detection ([#7333](https://github.com/facebook/jest/pull/7333))
76+
- `[jest-haste-map]` Fix `require` detection with trailing commas and ignore `import typeof` modules ([#7385](https://github.com/facebook/jest/pull/7385))
5777

5878
### Chore & Maintenance
5979

80+
- `[jest-watcher]` Standardize filenames ([#7314](https://github.com/facebook/jest/pull/7314))
81+
- `[jest-circus]` Standardize file naming in `jest-circus` ([#7301](https://github.com/facebook/jest/pull/7301))
6082
- `[docs]` Add synchronous test.each setup ([#7150](https://github.com/facebook/jest/pull/7150))
6183
- `[docs]` Add `this.extend` to the Custom Matchers API reference ([#7130](https://github.com/facebook/jest/pull/7130))
6284
- `[docs]` Fix default value for `coverageReporters` value in configuration docs ([#7126](https://github.com/facebook/jest/pull/7126))
@@ -81,6 +103,15 @@
81103
- `[tests]` Free tests from the dependency on value of FORCE_COLOR ([#6585](https://github.com/facebook/jest/pull/6585/files))
82104
- `[jest-diff]` Standardize filenames ([#7238](https://github.com/facebook/jest/pull/7238))
83105
- `[*]` Add babel plugin to make sure Jest is unaffected by fake Promise implementations ([#7225](https://github.com/facebook/jest/pull/7225))
106+
- `[jest-haste-map]` Standardize filenames ([#7266](https://github.com/facebook/jest/pull/7266))
107+
- `[*]` [**BREAKING**] Require Node.js 6+ for all packages ([#7258](https://github.com/facebook/jest/pull/7258))
108+
- `[docs]` Add correct default value for `testUrl` config option ([#7277](https://github.com/facebook/jest/pull/7277))
109+
- `[jest-util]` [**BREAKING**] Remove long-deprecated globals for fake timers ([#7285](https://github.com/facebook/jest/pull/7285))
110+
- `[docs]` Remove duplicate code in `MockFunctions` ([#7297](https://github.com/facebook/jest/pull/7297))
111+
- `[jest-worker]` Standardize filenames ([#7316](https://github.com/facebook/jest/pull/7316))
112+
- `[pretty-format]` Standardize filenames ([#7316](https://github.com/facebook/jest/pull/7316))
113+
- `[*]` Add check for Facebook copyright headers on CI ([#7370](https://github.com/facebook/jest/pull/7370))
114+
- `[jest-haste-map]` Refactor `dependencyExtractor` and tests ([#7385](https://github.com/facebook/jest/pull/7385))
84115

85116
### Performance
86117

@@ -172,9 +203,6 @@
172203
### Fixes
173204

174205
- `[jest-haste-map]` Optimize watchman crawler by using `glob` on initial query ([#6689](https://github.com/facebook/jest/pull/6689))
175-
176-
### Fixes
177-
178206
- `[pretty-format]` Fix formatting of invalid Date objects ([#6635](https://github.com/facebook/jest/pull/6635))
179207

180208
## 23.4.0
@@ -335,7 +363,7 @@
335363
- `[jest-diff]` Support returning diff from oneline strings ([#6221](https://github.com/facebook/jest/pull/6221))
336364
- `[expect]` Improve return matchers ([#6172](https://github.com/facebook/jest/pull/6172))
337365
- `[jest-cli]` Overhaul watch plugin hooks names ([#6249](https://github.com/facebook/jest/pull/6249))
338-
- `[jest-mock]` Include tracked call results in serialized mock ([#6244](https://github.com/facebook/jest/pull/6244))
366+
- `[jest-mock]` [**BREAKING**] Include tracked call results in serialized mock ([#6244](https://github.com/facebook/jest/pull/6244))
339367

340368
### Fixes
341369

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<a href="http://badge.fury.io/js/jest"><img src="https://badge.fury.io/js/jest.svg" alt="npm version"></a>
1313
<a href="https://dependabot.com/compatibility-score.html?dependency-name=jest&amp;package-manager=npm_and_yarn&amp;version-scheme=semver"><img src="https://api.dependabot.com/badges/compatibility_score?dependency-name=jest&amp;package-manager=npm_and_yarn&amp;version-scheme=semver" alt="SemVer">
1414
<a href="https://twitter.com/acdlite/status/974390255393505280"><img src="https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg" alt="Blazing Fast"></a>
15+
<a href="https://github.com/facebook/jest/pulls"><img src="https://img.shields.io/badge/PRs%20-welcome-brightgreen.svg" alt="PR's welcome"></a>
1516
</p>
1617
<p align="center">
1718
<a href="#backers"><img src="https://opencollective.com/jest/backers/badge.svg" alt="Backers on Open Collective"></a>

docs/Configuration.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ Jest will fail if:
257257
- The `./src/api/very-important-module.js` file has less than 100% coverage.
258258
- Every remaining file combined has less than 50% coverage (`global`).
259259

260+
### `dependencyExtractor` [string]
261+
262+
Default: `undefined`
263+
264+
This option allows the use of a custom dependency extractor. It must be a node module that exports an object with an `extract` function expecting a string as the first argument for the code to analyze and Jest's dependency extractor as the second argument (in case you only want to extend it).
265+
266+
The function should return an iterable (`Array`, `Set`, etc.) with the dependencies found in the code.
267+
268+
That module can also contain a `getCacheKey` function to generate a cache key to determine if the logic has changed and any cached artifacts relying on it should be discarded.
269+
260270
### `errorOnDeprecated` [boolean]
261271

262272
Default: `false`
@@ -609,6 +619,8 @@ This option allows you to use a custom runner instead of Jest's default test run
609619
- [`jest-runner-tsc`](https://github.com/azz/jest-runner-tsc)
610620
- [`jest-runner-prettier`](https://github.com/keplersj/jest-runner-prettier)
611621

622+
_Note: The `runner` property value can omit the `jest-runner-` prefix of the package name._
623+
612624
To write a test-runner, export a class with which accepts `globalConfig` in the constructor, and has a `runTests` method with the signature:
613625

614626
```ts
@@ -905,7 +917,7 @@ An example of such function can be found in our default [jasmine2 test runner pa
905917

906918
### `testURL` [string]
907919

908-
Default: `about:blank`
920+
Default: `http://localhost`
909921

910922
This option sets the URL for the jsdom environment. It is reflected in properties such as `location.href`.
911923

@@ -962,3 +974,37 @@ Default: `[]`
962974
An array of RegExp patterns that are matched against all source file paths before re-running tests in watch mode. If the file path matches any of the patterns, when it is updated, it will not trigger a re-run of tests.
963975

964976
These patterns match against the full path. Use the `<rootDir>` string token to include the path to your project's root directory to prevent it from accidentally ignoring all of your files in different environments that may have different root directories. Example: `["<rootDir>/node_modules/"]`.
977+
978+
### `watchPlugins` [array<string | [string, Object]>]
979+
980+
Default: `[]`
981+
982+
This option allows you to use a custom watch plugins. Read more about watch plugins [here](watch-plugins).
983+
984+
Examples of watch plugins include:
985+
986+
- [`jest-watch-master`](https://github.com/rickhanlonii/jest-watch-master)
987+
- [`jest-watch-select-projects`](https://github.com/rogeliog/jest-watch-select-projects)
988+
- [`jest-watch-suspend`](https://github.com/unional/jest-watch-suspend)
989+
- [`jest-watch-typeahead`](https://github.com/jest-community/jest-watch-typeahead)
990+
- [`jest-watch-yarn-workspaces`](https://github.com/cameronhunter/jest-watch-directories/tree/master/packages/jest-watch-yarn-workspaces)
991+
992+
_Note: The values in the `watchPlugins` property value can omit the `jest-watch-` prefix of the package name._
993+
994+
### `//` [string]
995+
996+
No default
997+
998+
This option allow comments in `package.json`. Include the comment text as the value of this key anywhere in `package.json`.
999+
1000+
Example:
1001+
1002+
```json
1003+
{
1004+
"name": "my-project",
1005+
"jest": {
1006+
"//": "Comment goes here",
1007+
"verbose": true
1008+
}
1009+
}
1010+
```

docs/GettingStarted.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Or [`npm`](https://www.npmjs.com/):
1515
npm install --save-dev jest
1616
```
1717

18+
Note: Jest documentation uses `yarn` commands, but `npm` will also work. You can compare `yarn` and `npm` commands in the [yarn docs, here](https://yarnpkg.com/en/docs/migrating-from-npm#toc-cli-commands-comparison).
19+
1820
Let's get started by writing a test for a hypothetical function that adds two numbers. First, create a `sum.js` file:
1921

2022
```javascript
@@ -44,7 +46,7 @@ Add the following section to your `package.json`:
4446
}
4547
```
4648

47-
Finally, run `yarn test` and Jest will print this message:
49+
Finally, run `yarn test` or `npm run test` and Jest will print this message:
4850

4951
```bash
5052
PASS ./sum.test.js
@@ -57,7 +59,7 @@ This test used `expect` and `toBe` to test that two values were exactly identica
5759

5860
## Running from command line
5961

60-
You can run Jest directly from the CLI (if it's globally available in your `PATH`, e.g. by `yarn global add jest`) with a variety of useful options.
62+
You can run Jest directly from the CLI (if it's globally available in your `PATH`, e.g. by `yarn global add jest` or `npm install jest --global`) with a variety of useful options.
6163

6264
Here's how to run Jest on files matching `my-test`, using `config.json` as a configuration file and display a native OS notification after the run:
6365

@@ -79,7 +81,7 @@ jest --init
7981

8082
### Using Babel
8183

82-
To use [Babel](http://babeljs.io/), install the `babel-jest` and `@babel/core` packages:
84+
To use [Babel](http://babeljs.io/), install the `babel-jest` and `@babel/core` packages via `yarn`:
8385

8486
```bash
8587
yarn add --dev babel-jest @babel/core

0 commit comments

Comments
 (0)