diff --git a/CHANGELOG.md b/CHANGELOG.md index 7048c2c3b311..fcb07c0a7467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,17 @@ ### Fixes -* `[expect]` Fail test when the types of `stringContaining` and `stringMatching` matchers do not match. -* `[jest-cli]` Treat dumb terminals as noninteractive ([#5237](https://github.com/facebook/jest/pull/5237)) +* `[expect]` Fail test when the types of `stringContaining` and `stringMatching` + matchers do not match. ([#5069](https://github.com/facebook/jest/pull/5069)) +* `[jest-cli]` Treat dumb terminals as noninteractive + ([#5237](https://github.com/facebook/jest/pull/5237)) * `[jest-cli]` `jest --onlyChanged --changedFilesWithAncestor` now also works with git. ([#5189](https://github.com/facebook/jest/pull/5189)) * `[jest-config]` fix unexpected condition to avoid infinite recursion in Windows platform. ([#5161](https://github.com/facebook/jest/pull/5161)) -* `[jest-config]` Escape parentheses and other glob characters in `rootDir` before interpolating with `testMatch`. ([#4838](https://github.com/facebook/jest/issues/4838)) +* `[jest-config]` Escape parentheses and other glob characters in `rootDir` + before interpolating with `testMatch`. + ([#4838](https://github.com/facebook/jest/issues/4838)) * `[jest-regex-util]` Fix breaking change in `--testPathPattern` ([#5230](https://github.com/facebook/jest/pull/5230)) * `[expect]` Do not override `Error` stack (with `Error.captureStackTrace`) for @@ -33,15 +37,17 @@ * `[jest-runner]` test environments are now passed a new `options` parameter. Currently this only has the `console` which is the test console that Jest will expose to tests. ([#5223](https://github.com/facebook/jest/issues/5223)) -* `[jest-environment-jsdom]` pass the `options.console` to a custom - instance of `virtualConsole` so jsdom is using the same console as the - test. ([#5223](https://github.com/facebook/jest/issues/5223)) +* `[jest-environment-jsdom]` pass the `options.console` to a custom instance of + `virtualConsole` so jsdom is using the same console as the test. + ([#5223](https://github.com/facebook/jest/issues/5223)) ### Chore & Maintenance * `[docs]` Describe the order of execution of describe and test blocks. - ([#5217](https://github.com/facebook/jest/pull/5217), [#5238](https://github.com/facebook/jest/pull/5238)) -* `[docs]` Add a note on `moduleNameMapper` ordering. ([#5249](https://github.com/facebook/jest/pull/5249)) + ([#5217](https://github.com/facebook/jest/pull/5217), + [#5238](https://github.com/facebook/jest/pull/5238)) +* `[docs]` Add a note on `moduleNameMapper` ordering. + ([#5249](https://github.com/facebook/jest/pull/5249)) ## jest 22.0.4 diff --git a/docs/Configuration.md b/docs/Configuration.md index 5641f487e6b4..a49d11769c81 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -386,8 +386,8 @@ Example: } ``` -The order in which the mappings are defined matters. Patterns are checked one -by one until one fits. The most specific rule should be listed first. +The order in which the mappings are defined matters. Patterns are checked one by +one until one fits. The most specific rule should be listed first. _Note: If you provide module name without boundaries `^$` it may cause hard to spot errors. E.g. `relay` will replace all modules which contain `relay` as a @@ -795,9 +795,9 @@ test('use jsdom in this test file', () => { You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and -`runScript` methods. You can also pass variables from this module to your -test suites by assigning them to `this.global` object – this will -make them available in your test suites as global variables. +`runScript` methods. You can also pass variables from this module to your test +suites by assigning them to `this.global` object – this will make them +available in your test suites as global variables. ##### available in Jest **22.0.0+** @@ -839,8 +839,7 @@ let someGlobalObject; beforeAll(() => { someGlobalObject = global.someGlobalObject; -}) - +}); ``` ### `testEnvironmentOptions` [Object] diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index 64dcfbf982e5..0ef8f8801478 100644 --- a/docs/JestObjectAPI.md +++ b/docs/JestObjectAPI.md @@ -420,15 +420,19 @@ test('plays video', () => { ``` ### `jest.spyOn(object, methodName, accessType?)` -##### available in Jest **x.x.x+** -Since Jest x.x.x+, the `jest.spyOn` method takes an optional third argument that can be `'get'` or `'get'` in order to install a spy as a getter or a setter respectively. This is also needed when you need a spy an existing getter/setter method. +##### available in Jest **22.1.0+** + +Since Jest 22.1.0+, the `jest.spyOn` method takes an optional third argument of +`accessType` that can be either `'get'` or `'set'`, which proves to be useful +when you want to spy on a getter or a setter, respectively. Example: ```js const video = { - get play() { // it's a getter! + // it's a getter! + get play() { return true; }, }; @@ -437,12 +441,13 @@ module.exports = video; const audio = { _volume: false, - set volume(value) { // it's a setter! + // it's a setter! + set volume(value) { this._volume = value; }, get volume() { return this._volume; - } + }, }; module.exports = video; diff --git a/docs/SetupAndTeardown.md b/docs/SetupAndTeardown.md index 2307507f2252..c5d34e9f75a4 100644 --- a/docs/SetupAndTeardown.md +++ b/docs/SetupAndTeardown.md @@ -149,39 +149,43 @@ describe('Scoped / Nested block', () => { ### Order of execution of describe and test blocks -Jest executes all describe handlers in a test file *before* it executes any of the actual tests. This is another reason to do setup and teardown in `before*` and `after*` handlers rather in the describe blocks. Once the describe blocks are complete, by default Jest runs all the tests serially in the order they were encountered in the collection phase, waiting for each to finish and be tidied up before moving on. +Jest executes all describe handlers in a test file _before_ it executes any of +the actual tests. This is another reason to do setup and teardown in `before*` +and `after*` handlers rather in the describe blocks. Once the describe blocks +are complete, by default Jest runs all the tests serially in the order they were +encountered in the collection phase, waiting for each to finish and be tidied up +before moving on. Consider the following illustrative test file and output: ```js describe('outer', () => { + console.log('describe outer-a'); + + describe('describe inner 1', () => { + console.log('describe inner 1'); + test('test 1', () => { + console.log('test for describe inner 1'); + expect(true).toEqual(true); + }); + }); + + console.log('describe outer-b'); + + test('test 1', () => { + console.log('test for describe outer'); + expect(true).toEqual(true); + }); + + describe('describe inner 2', () => { + console.log('describe inner 2'); + test('test for describe inner 2', () => { + console.log('test for describe inner 2'); + expect(false).toEqual(false); + }); + }); - console.log('describe outer-a'); - - describe('describe inner 1', () => { - console.log('describe inner 1'); - test('test 1', () => { - console.log('test for describe inner 1'); - expect(true).toEqual(true); - }); - }); - - console.log('describe outer-b'); - - test('test 1', () => { - console.log('test for describe outer'); - expect(true).toEqual(true); - }); - - describe('describe inner 2', () => { - console.log('describe inner 2'); - test('test for describe inner 2', () => { - console.log('test for describe inner 2'); - expect(false).toEqual(false); - }) - }); - - console.log('describe outer-c'); + console.log('describe outer-c'); }); // describe outer-a