You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`[pretty-format]` Option to not escape strings in diff messages ([#5661](https://github.com/facebook/jest/pull/5661))
7
+
-`[jest-haste-map]` Add `getFileIterator` to `HasteFS` for faster file iteration ([#7010](https://github.com/facebook/jest/pull/7010)).
8
+
-`[jest-worker]`[**BREAKING**] Add functionality to call a `setup` method in the worker before the first call and a `teardown` method when ending the farm ([#7014](https://github.com/facebook/jest/pull/7014)).
9
+
-`[jest-config]`[**BREAKING**] Set default `notifyMode` to `failure-change` ([#7024](https://github.com/facebook/jest/pull/7024))
-`[jest-each]` Add each array validation check ([#7033](https://github.com/facebook/jest/pull/7033))
15
+
-`[jest-haste-map]`[**BREAKING**] Replace internal data structures to improve performance ([#6960](https://github.com/facebook/jest/pull/6960))
16
+
-`[jest-haste-map]` Use relative paths to allow remote caching ([#7020](https://github.com/facebook/jest/pull/7020))
17
+
-`[jest-haste-map]` Do not visit again files with the same sha-1 ([#6990](https://github.com/facebook/jest/pull/6990))
18
+
-`[jest-jasmine2]` Fix memory leak in Error objects hold by the framework ([#6965](https://github.com/facebook/jest/pull/6965))
19
+
-`[jest-haste-map]` Fixed Haste whitelist generation for scoped modules on Windows ([#6980](https://github.com/facebook/jest/pull/6980))
20
+
-`[jest-mock]` Fix inheritance of static properties and methods in mocks ([#7003](https://github.com/facebook/jest/pull/7003))
21
+
-`[jest-mock]` Fix mocking objects without `Object.prototype` in their prototype chain ([#7003](https://github.com/facebook/jest/pull/7003))
22
+
-`[jest-mock]` Check `_isMockFunction` is true rather than truthy on potential mocks ([#7017](https://github.com/facebook/jest/pull/7017))
23
+
-`[jest-cli]` Update jest-cli to show git ref in message when using `changedSince` ([#7028](https://github.com/facebook/jest/pull/7028))
24
+
-`[jest-jasmine2`] Fix crash when test return Promise rejected with null ([#7049](https://github.com/facebook/jest/pull/7049))
25
+
-`[jest-runtime]` Check `_isMockFunction` is true rather than truthy on potential global mocks ([#7017](https://github.com/facebook/jest/pull/7017))
26
+
-`[jest-jasmine]` Show proper error message from async `assert` errors ([#6821](https://github.com/facebook/jest/pull/6821))
27
+
28
+
### Chore & Maintenance
29
+
30
+
-`[docs]` Add link for jest-extended in expect docs ([#7078](https://github.com/facebook/jest/pull/7078))
31
+
-`[jest-util]` Add ErrorWithStack class ([#7067](https://github.com/facebook/jest/pull/7067))
-`[docs]` Explain how to rewrite assertions to avoid large irrelevant diff ([#6971](https://github.com/facebook/jest/pull/6971))
35
+
-`[examples]` add example using Babel 7 ([#6983](https://github.com/facebook/jest/pull/6983))
36
+
-`[docs]` Replace shallow equality with referential identity in `ExpectAPI.md` ([#6991](https://github.com/facebook/jest/pull/6991))
37
+
-`[jest-changed-files]` Refactor to use `execa` over `child_process` ([#6987](https://github.com/facebook/jest/pull/6987))
-`[scripts]` Don’t make empty subfolders for ignored files in build folder ([#7001](https://github.com/facebook/jest/pull/7001))
40
+
41
+
## 23.6.0
42
+
43
+
### Features
44
+
45
+
-`[jest-cli]` Add `changedSince` to allowed watch mode configs ([#6955](https://github.com/facebook/jest/pull/6955))
5
46
-`[babel-jest]` Add support for `babel.config.js` added in Babel 7.0.0 ([#6911](https://github.com/facebook/jest/pull/6911))
6
47
-`[jest-resolve]` Add support for an experimental `mapper` option (Watchman crawler only) that adds virtual files to the Haste map ([#6940](https://github.com/facebook/jest/pull/6940))
7
48
@@ -23,6 +64,8 @@
23
64
-`[docs]` Improve the documentation regarding preset configuration ([#6864](https://github.com/facebook/jest/issues/6864))
24
65
-`[docs]` Clarify usage of `--projects` CLI option ([#6872](https://github.com/facebook/jest/pull/6872))
-`[scripts]` Don’t remove node_modules from subdirectories of presets in e2e tests ([#6948](https://github.com/facebook/jest/pull/6948))
68
+
-`[diff-sequences]` Double-check number of differences in tests ([#6953](https://github.com/facebook/jest/pull/6953))
Note: Replace `<your_username>` with your GitHub username
34
34
35
-
2. Jest uses [Yarn](https://code.facebook.com/posts/1840075619545360) for running development scripts. If you haven't already done so, please [install yarn](https://yarnpkg.com/en/docs/install).
35
+
1. Jest uses [Yarn](https://code.facebook.com/posts/1840075619545360) for running development scripts. If you haven't already done so, please [install yarn](https://yarnpkg.com/en/docs/install).
36
+
37
+
1. Make sure you have `python` installed (v2.7 is recommended, v3.x.x is not supported). Python is required by [node-gyp](https://github.com/nodejs/node-gyp) that is used when running `yarn install`.
38
+
39
+
To check your version of Python and ensure it's installed you can type:
40
+
41
+
```sh
42
+
python --version
43
+
```
36
44
37
-
3. Run `yarn install`. On Windows: To install [Yarn](https://yarnpkg.com/en/docs/install#windows-tab) on Windows you may need to download either node.js or Chocolatey<br />
45
+
1. Run `yarn install`. On Windows: To install [Yarn](https://yarnpkg.com/en/docs/install#windows-tab) on Windows you may need to download either node.js or Chocolatey<br />
38
46
39
47
```sh
40
48
yarn install
@@ -46,35 +54,62 @@ _Before_ submitting a pull request, please make sure the following is done…
46
54
yarn --version
47
55
```
48
56
49
-
4. If you've added code that should be tested, add tests. You can use watch mode that continuously transforms changed files to make your life easier.
57
+
1. If you've added code that should be tested, add tests. You can use watch mode that continuously transforms changed files to make your life easier.
50
58
51
59
```sh
52
60
# in the background
53
61
yarn run watch
54
62
```
55
63
56
-
5. If you've changed APIs, update the documentation.
64
+
1. If you've changed APIs, update the documentation.
57
65
58
-
6. Ensure the test suite passes via `yarn test`. To run the test suite you may need to install [Mercurial](https://www.mercurial-scm.org/) (`hg`). On macOS, this can be done using [homebrew](http://brew.sh/): `brew install hg`.
66
+
1. Ensure the test suite passes via `yarn test`. To run the test suite you may need to install [Mercurial](https://www.mercurial-scm.org/) (`hg`). On macOS, this can be done using [homebrew](http://brew.sh/): `brew install hg`.
59
67
60
-
```sh
61
-
brew install hg # maybe
62
-
yarn test
68
+
```sh-session
69
+
$ brew install hg # maybe
70
+
$ yarn test
63
71
```
64
72
65
-
7. If you haven't already, complete the CLA.
73
+
1. If you haven't already, complete the CLA.
74
+
75
+
#### Testing
76
+
77
+
Code that is written needs to be tested to ensure that it achieves the desired behaviour. Tests either fall into a unit test or an integration test.
78
+
79
+
##### Unit tests
80
+
81
+
Some of the packages within jest have a `__tests__` directory. This is where unit tests reside in. If the scope of your work only requires a unit test, this is where you will write it in. Tests here usually don't require much if any setup.
82
+
83
+
##### Integration tests
84
+
85
+
There will be situations however where the work you have done cannot be tested alone using unit tests. In situations like this, you should write an integration test for your code. The integration tests reside within the `e2e` directory. Within this directory, there is a `__tests__` directory. This is where you will write the integration test itself. The tests within this directory execute jest itself using `runJest.js` and assertions are usually made on one if not all the output of the following `status`, `stdout` and `stderr`. The other sub directories within the `e2e` directory are where you will write the files that jest will run for your integration tests. Feel free to take a look at any of the tests in the `__tests__` directory within `e2e` to have a better sense of how it is currently being done.
86
+
87
+
It is possible to run the integration test itself manually to inspect that the new behaviour is indeed correct. Here is a small code snippet of how to do just that. This is useful when debugging a failing test.
88
+
89
+
```bash
90
+
$ cd e2e/clear-cache
91
+
$ node ../../packages/jest-cli/bin/jest.js # It is possible to use node --inspect or ndb
92
+
PASS __tests__/clear_cache.test.js
93
+
✓ stub (3ms)
94
+
95
+
Test Suites: 1 passed, 1 total
96
+
Tests: 1 passed, 1 total
97
+
Snapshots: 0 total
98
+
Time: 0.232s, estimated 1s
99
+
Ran all test suites.
100
+
```
66
101
67
102
#### Additional Workflow for any changes made to website or docs
68
103
69
104
If you are making changes to the website or documentation, test the website folder and run the server to check if your changes are being displayed accurately.
70
105
71
106
1. Locate to the website directory and install any website specific dependencies by typing in `yarn`. Following steps are to be followed for this purpose from the root directory.
72
-
```sh
73
-
cd website # Only needed if you are not already in the website directory
74
-
yarn
75
-
yarn start
107
+
```sh-session
108
+
$ cd website # Only needed if you are not already in the website directory
109
+
$ yarn
110
+
$ yarn start
76
111
```
77
-
2. 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.
112
+
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.
78
113
79
114
### Contributor License Agreement (CLA)
80
115
@@ -86,34 +121,34 @@ In order to accept your pull request, we need you to submit a CLA. You only need
86
121
87
122
To link `jest` on the command line to `jest-cli/bin/jest.js` in a development build:
88
123
89
-
```sh
90
-
cd /path/to/your/Jest_clone/packages/jest-cli
91
-
yarn link
124
+
```sh-session
125
+
$ cd /path/to/your/Jest_clone/packages/jest-cli
126
+
$ yarn link
92
127
```
93
128
94
129
To build Jest:
95
130
96
-
```sh
97
-
cd /path/to/your/Jest_clone
131
+
```sh-session
132
+
$ cd /path/to/your/Jest_clone
98
133
99
134
# Do one of the following:
100
135
101
136
# Check out a commit from another contributor, and then
102
-
yarn run build
137
+
$ yarn run build
103
138
104
139
# Or, save your changes to Jest, and then
105
-
yarn test # which also builds Jest
140
+
$ yarn test# which also builds Jest
106
141
```
107
142
108
143
To run tests in another project with the development build of Jest:
109
144
110
-
```sh
111
-
cd /path/to/another/project
145
+
```sh-session
146
+
$ cd /path/to/another/project
112
147
113
148
# link development build to the other project
114
-
yarn link jest-cli
149
+
$ yarn link jest-cli
115
150
116
-
jest [options] # run jest-cli/bin/jest.js in the development build
151
+
$ jest [options] # run jest-cli/bin/jest.js in the development build
117
152
```
118
153
119
154
- To decide whether to specify any options, see `test` under `scripts` in the `package.json` file of the other project.
**👩🏻💻 Developer Ready**: Complete and ready to set-up JavaScript testing solution. Works out of the box for any React project.
@@ -101,10 +102,10 @@ If you'd like to learn more about running `jest` through the command line, take
101
102
102
103
[Babel](http://babeljs.io/) is automatically handled by Jest using `babel-jest`. You don't need install anything extra for using Babel.
103
104
104
-
> Note: If you are using a babel version 7 then you need to install `babel-core@^7.0.0-0` and `@babel/core` with the following command:
105
+
> Note: If you are using Babel version 7 then you need to install `babel-jest`, `babel-core@^7.0.0-bridge.0` and `@babel/core` with the following command:
Don't forget to add a [`.babelrc`](https://babeljs.io/docs/usage/babelrc/) file in your project's root folder. For example, if you are using ES6 and [React.js](https://reactjs.org) with the [`babel-preset-env`](https://babeljs.io/docs/plugins/preset-env/) and [`babel-preset-react`](https://babeljs.io/docs/plugins/preset-react/) presets:
Copy file name to clipboardExpand all lines: docs/CLI.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -227,6 +227,12 @@ Run tests with specified reporters. [Reporter options](configuration#reporters-a
227
227
228
228
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.
229
229
230
+
### `--runTestsByPath`
231
+
232
+
Run only the tests that were specified with their exact paths.
233
+
234
+
_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_
235
+
230
236
### `--setupTestFrameworkScriptFile=<file>`
231
237
232
238
The path to a module that runs some code to configure or set up the testing framework before each test. Beware that files imported by the setup script will not be mocked during testing.
@@ -642,6 +642,29 @@ If you want this path to be [relative to the root directory of your project](#ro
642
642
643
643
For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in this module.
644
644
645
+
### `snapshotResolver`[string]
646
+
647
+
Default: `undefined`
648
+
649
+
The path to a module that can resolve test<->snapshot path. This config option lets you customize where Jest stores that snapshot files on disk.
@@ -896,7 +919,7 @@ A map from regular expressions to paths to transformers. A transformer is a modu
896
919
897
920
Examples of such compilers include [Babel](https://babeljs.io/), [TypeScript](http://www.typescriptlang.org/) and [async-to-gen](http://github.com/leebyron/async-to-gen#jest).
898
921
899
-
_Note: a transformer is only ran once per file unless the file has changed. During development of a transformer it can be useful to run Jest with `--no-cache` to frequently [delete Jest's cache](Troubleshooting.md#caching-issues)._
922
+
_Note: a transformer is only run once per file unless the file has changed. During development of a transformer it can be useful to run Jest with `--no-cache` to frequently [delete Jest's cache](Troubleshooting.md#caching-issues)._
900
923
901
924
_Note: if you are using the `babel-jest` transformer and want to use an additional code preprocessor, keep in mind that when "transform" is overwritten in any way the `babel-jest` is not loaded automatically anymore. If you want to use it to compile JavaScript code it has to be explicitly defined. See [babel-jest plugin](https://github.com/facebook/jest/tree/master/packages/babel-jest#setup)_
0 commit comments