Skip to content

Commit

Permalink
Merge branch 'master' into get-rid-of-node6
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Aug 16, 2019
2 parents de45e84 + 3cdbd55 commit 3cfbe1b
Show file tree
Hide file tree
Showing 283 changed files with 5,154 additions and 2,679 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- restore-cache: *restore-cache
- run: yarn --no-progress --frozen-lockfile
- save-cache: *save-cache
- run: yarn lint --format junit -o reports/junit/js-lint-results.xml && yarn lint-es5-build --format junit -o reports/junit/js-es5-lint-results.xml && yarn lint:md:ci && yarn check-copyright-headers
- run: yarn lint --format junit -o reports/junit/js-lint-results.xml && yarn lint-es5-build --format junit -o reports/junit/js-es5-lint-results.xml && yarn lint:prettier:ci && yarn check-copyright-headers
- store_test_results:
path: reports/junit

Expand Down
6 changes: 5 additions & 1 deletion .circleci/website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ else
sudo dpkg -i crowdin.deb
# translations upload/download
yarn crowdin-upload
yarn crowdin-download
# download only enabled languages
for lang in ja es-ES ro zh-CN pt-BR ru uk
do
yarn crowdin-download -l $lang
done
# build and publish website
GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages
else
Expand Down
10 changes: 9 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
#
# Some of these options are also respected by Prettier

root = true

[*]
indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{*.md,*.snap}]
[*.{md,snap}]
trim_trailing_whitespace = false
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@

### Features

### Fixes

### Chore & Maintenance

### Performance

## 24.9.0

### Features

- `[expect]` Highlight substring differences when matcher fails, part 1 ([#8448](https://github.com/facebook/jest/pull/8448))
- `[expect]` Highlight substring differences when matcher fails, part 2 ([#8528](https://github.com/facebook/jest/pull/8528))
- `[expect]` Improve report when mock-spy matcher fails, part 1 ([#8640](https://github.com/facebook/jest/pull/8640))
- `[expect]` Improve report when mock-spy matcher fails, part 2 ([#8649](https://github.com/facebook/jest/pull/8649))
- `[expect]` Improve report when mock-spy matcher fails, part 3 ([#8697](https://github.com/facebook/jest/pull/8697))
- `[expect]` Improve report when mock-spy matcher fails, part 4 ([#8710](https://github.com/facebook/jest/pull/8710))
- `[expect]` Throw matcher error when received cannot be jasmine spy ([#8747](https://github.com/facebook/jest/pull/8747))
- `[expect]` Improve report when negative CalledWith assertion fails ([#8755](https://github.com/facebook/jest/pull/8755))
- `[expect]` Improve report when positive CalledWith assertion fails ([#8771](https://github.com/facebook/jest/pull/8771))
- `[expect]` Display equal values for ReturnedWith similar to CalledWith ([#8791](https://github.com/facebook/jest/pull/8791))
- `[expect, jest-snapshot]` Change color from green for some args in matcher hints ([#8812](https://github.com/facebook/jest/pull/8812))
- `[jest-snapshot]` Highlight substring differences when matcher fails, part 3 ([#8569](https://github.com/facebook/jest/pull/8569))
- `[jest-core]` Improve report when snapshots are obsolete ([#8448](https://github.com/facebook/jest/pull/8665))
- `[jest-cli]` Improve chai support (with detailed output, to match jest exceptions) ([#8454](https://github.com/facebook/jest/pull/8454))
- `[*]` Manage the global timeout with `--testTimeout` command line argument. ([#8456](https://github.com/facebook/jest/pull/8456))
- `[pretty-format]` Render custom displayName of memoized components
- `[jest-validate]` Allow `maxWorkers` as part of the `jest.config.js` ([#8565](https://github.com/facebook/jest/pull/8565))
- `[jest-runtime]` Allow passing configuration objects to transformers ([#7288](https://github.com/facebook/jest/pull/7288))
- `[@jest/core, @jest/test-sequencer]` Support async sort in custom `testSequencer` ([#8642](https://github.com/facebook/jest/pull/8642))
- `[jest-runtime, @jest/fake-timers]` Add `jest.advanceTimersToNextTimer` ([#8713](https://github.com/facebook/jest/pull/8713))
- `[@jest-transform]` Extract transforming require logic within `jest-core` into `@jest-transform` ([#8756](https://github.com/facebook/jest/pull/8756))
- `[jest-matcher-utils]` Add color options to `matcherHint` ([#8795](https://github.com/facebook/jest/pull/8795))
- `[jest-circus/jest-jasmine2]` Give clearer output for Node assert errors ([#8792](https://github.com/facebook/jest/pull/8792))
- `[jest-runner]` Export all types in the type signature of `jest-runner` ([#8825](https://github.com/facebook/jest/pull/8825))`

### Fixes

Expand All @@ -26,6 +48,8 @@
- `[jest-core]` Fix incorrect `passWithNoTests` warning ([#8595](https://github.com/facebook/jest/pull/8595))
- `[jest-snapshots]` Fix test retries that contain snapshots ([#8629](https://github.com/facebook/jest/pull/8629))
- `[jest-mock]` Fix incorrect assignments when restoring mocks in instances where they originally didn't exist ([#8631](https://github.com/facebook/jest/pull/8631))
- `[expect]` Fix stack overflow when matching objects with circular references ([#8687](https://github.com/facebook/jest/pull/8687))
- `[jest-haste-map]` Workaround a node >=12.5.0 bug that causes the process not to exit after tests have completed and cancerous memory growth ([#8787](https://github.com/facebook/jest/pull/8787))

### Chore & Maintenance

Expand All @@ -35,10 +59,21 @@
- `[docs]` Add information about using `jest.doMock` with ES6 imports ([#8573](https://github.com/facebook/jest/pull/8573))
- `[docs]` Fix variable name in custom-matcher-api code example ([#8582](https://github.com/facebook/jest/pull/8582))
- `[docs]` Fix example used in custom environment docs ([#8617](https://github.com/facebook/jest/pull/8617))
- `[docs]` Updated react tutorial to refer to new package of react-testing-library (@testing-library/react) ([#8753](https://github.com/facebook/jest/pull/8753))
- `[docs]` Updated imports of react-testing-library to @testing-library/react in website ([#8757](https://github.com/facebook/jest/pull/8757))
- `[jest-core]` Add `getVersion` (moved from `jest-cli`) ([#8706](https://github.com/facebook/jest/pull/8706))
- `[docs]` Fix MockFunctions example that was using toContain instead of toContainEqual ([#8765](https://github.com/facebook/jest/pull/8765))
- `[*]` Make sure copyright header comment includes license ([#8783](https://github.com/facebook/jest/pull/8783))
- `[*]` Check copyright and license as one joined substring ([#8815](https://github.com/facebook/jest/pull/8815))
- `[docs]` Fix WatchPlugins `jestHooks.shouldRunTestSuite` example that receives an object ([#8784](https://github.com/facebook/jest/pull/8784))
- `[*]` Enforce LF line endings ([#8809](https://github.com/facebook/jest/pull/8809))
- `[pretty-format]` Delete obsolete link and simplify structure in README ([#8824](https://github.com/facebook/jest/pull/8824))

### Performance

- `[jest-watcher]` Minor optimization for JestHook ([#8746](https://github.com/facebook/jest/pull/8746)
- `[@jest/reporters]` Prevent runaway CPU useage with `--notify` on macOS ([#8830](https://github.com/facebook/jest/issues/8830))

## 24.8.0

### Features
Expand Down
11 changes: 7 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
/**
* 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.
*/

module.exports = {
babelrcRoots: ['examples/*'],
overrides: [
{
plugins: [
'babel-plugin-typescript-strip-namespaces',
require.resolve(
'./scripts/babel-plugin-jest-replace-ts-export-assignment.js'
),
'babel-plugin-replace-ts-export-assignment',
],
presets: ['@babel/preset-typescript'],
test: /\.tsx?$/,
Expand Down
4 changes: 2 additions & 2 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ The glob patterns Jest uses to detect test files. By default it looks for `.js`,

See the [micromatch](https://github.com/jonschlinkert/micromatch) package for details of the patterns you can specify.

See also [`testRegex` [string | Array<string>]](#testregex-string), but note that you cannot specify both options.
See also [`testRegex` [string | array<string>]](#testregex-string-array-string), but note that you cannot specify both options.

### `testPathIgnorePatterns` [array<string>]

Expand All @@ -947,7 +947,7 @@ An array of regexp pattern strings that are matched against all test paths befor

These pattern strings 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>/build/", "<rootDir>/node_modules/"]`.

### `testRegex` [string | Array<string>]
### `testRegex` [string | array<string>]

Default: `(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$`

Expand Down
6 changes: 6 additions & 0 deletions docs/JestObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,12 @@ Executes only the macro-tasks that are currently pending (i.e., only the tasks t

This is useful for scenarios such as one where the module being tested schedules a `setTimeout()` whose callback schedules another `setTimeout()` recursively (meaning the scheduling never stops). In these scenarios, it's useful to be able to run forward in time by a single step at a time.

### `jest.advanceTimersToNextTimer(steps)`

Advances all timers by the needed milliseconds so that only the next timeouts/intervals will run.

Optionally, you can provide `steps`, so it will run `steps` amount of next timeouts/intervals.

### `jest.clearAllTimers()`

Removes any pending timers from the timer system.
Expand Down
2 changes: 1 addition & 1 deletion docs/ManualMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Manual mocks are used to stub out functionality with mock data. For example, ins

Manual mocks are defined by writing a module in a `__mocks__/` subdirectory immediately adjacent to the module. For example, to mock a module called `user` in the `models` directory, create a file called `user.js` and put it in the `models/__mocks__` directory. Note that the `__mocks__` folder is case-sensitive, so naming the directory `__MOCKS__` will break on some systems.

> When we require that module in our tests, then explicitly calling `jest.mock('./moduleName')` is **required**.
> When we require that module in our tests, explicitly calling `jest.mock('./moduleName')` is **required**.
## Mocking Node modules

Expand Down
2 changes: 1 addition & 1 deletion docs/MockFunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ These matchers are really just sugar for common forms of inspecting the `.mock`
expect(mockFunc.mock.calls.length).toBeGreaterThan(0);

// The mock function was called at least once with the specified args
expect(mockFunc.mock.calls).toContain([arg1, arg2]);
expect(mockFunc.mock.calls).toContainEqual([arg1, arg2]);

// The last call to the mock function was called with the specified args
expect(mockFunc.mock.calls[mockFunc.mock.calls.length - 1]).toEqual([
Expand Down
2 changes: 1 addition & 1 deletion docs/MoreResources.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ By now you should have a good idea of how Jest can make it easy to test your app

## Learn by example

You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/master/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/master/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/master/packages/react-relay/modern/__tests__), and [React Native](https://github.com/facebook/react-native/tree/master/Libraries/Animated/src/__tests__) projects.
You will find a number of example test cases in the [`examples`](https://github.com/facebook/jest/tree/master/examples) folder on GitHub. You can also learn from the excellent tests used by the [React](https://github.com/facebook/react/tree/master/packages/react/src/__tests__), [Relay](https://github.com/facebook/relay/tree/master/packages/react-relay/__tests__), and [React Native](https://github.com/facebook/react-native/tree/master/Libraries/Animated/src/__tests__) projects.

## Join the community

Expand Down
4 changes: 2 additions & 2 deletions docs/TutorialReact.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ If you'd like to assert, and manipulate your rendered components you can use [re

#### react-testing-library

You have to run `yarn add --dev react-testing-library` to use react-testing-library.
You have to run `yarn add --dev @testing-library/react` to use react-testing-library.

Let's implement a simple checkbox which swaps between two labels:
Expand Down Expand Up @@ -253,7 +253,7 @@ export default class CheckboxWithLabel extends React.Component {
```javascript
// __tests__/CheckboxWithLabel-test.js
import React from 'react';
import {render, fireEvent, cleanup} from 'react-testing-library';
import {render, fireEvent, cleanup} from '@testing-library/react';
import CheckboxWithLabel from '../CheckboxWithLabel';

// automatically unmount and cleanup DOM after the test is finished.
Expand Down
10 changes: 5 additions & 5 deletions docs/WatchPlugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MyWatchPlugin {

Below are the hooks available in Jest.

#### `jestHooks.shouldRunTestSuite(testPath)`
#### `jestHooks.shouldRunTestSuite(testSuiteInfo)`

Returns a boolean (or `Promise<boolean>` for handling asynchronous operations) to specify if a test should be run or not.

Expand All @@ -55,13 +55,13 @@ For example:
```javascript
class MyWatchPlugin {
apply(jestHooks) {
jestHooks.shouldRunTestSuite(testPath => {
return testPath.includes('my-keyword');
jestHooks.shouldRunTestSuite(testSuiteInfo => {
return testSuiteInfo.testPath.includes('my-keyword');
});

// or a promise
jestHooks.shouldRunTestSuite(testPath => {
return Promise.resolve(testPath.includes('my-keyword'));
jestHooks.shouldRunTestSuite(testSuiteInfo => {
return Promise.resolve(testSuiteInfo.testPath.includes('my-keyword'));
});
}
}
Expand Down
10 changes: 5 additions & 5 deletions e2e/__tests__/__snapshots__/beforeAllFiltered.ts.snap
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Correct BeforeAll run ensures the BeforeAll of ignored suite is not run 1`] = `
console.log __tests__/beforeAllFiltered.test.js:5
console.log __tests__/beforeAllFiltered.test.js:10
beforeAll 1
console.log __tests__/beforeAllFiltered.test.js:8
console.log __tests__/beforeAllFiltered.test.js:13
beforeEach 1
console.log __tests__/beforeAllFiltered.test.js:17
console.log __tests__/beforeAllFiltered.test.js:22
It Foo
console.log __tests__/beforeAllFiltered.test.js:11
console.log __tests__/beforeAllFiltered.test.js:16
afterEach 1
console.log __tests__/beforeAllFiltered.test.js:14
console.log __tests__/beforeAllFiltered.test.js:19
afterAll 1
`;
10 changes: 5 additions & 5 deletions e2e/__tests__/__snapshots__/beforeEachQueue.ts.snap
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Correct beforeEach order ensures the correct order for beforeEach 1`] = `
console.log __tests__/beforeEachQueue.test.js:5
console.log __tests__/beforeEachQueue.test.js:10
BeforeEach
console.log __tests__/beforeEachQueue.test.js:9
console.log __tests__/beforeEachQueue.test.js:14
It Foo
console.log __tests__/beforeEachQueue.test.js:12
console.log __tests__/beforeEachQueue.test.js:17
BeforeEach Inline Foo
console.log __tests__/beforeEachQueue.test.js:5
console.log __tests__/beforeEachQueue.test.js:10
BeforeEach
console.log __tests__/beforeEachQueue.test.js:17
console.log __tests__/beforeEachQueue.test.js:22
It Bar
`;
Loading

0 comments on commit 3cfbe1b

Please sign in to comment.