Skip to content

Commit

Permalink
Merge branch 'master' into override-plugin-key
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeliog committed Mar 27, 2018
2 parents 3836740 + 5bd6ee1 commit 78afdd1
Show file tree
Hide file tree
Showing 166 changed files with 22,951 additions and 1,237 deletions.
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ repository on GitHub that we can `yarn install` and `yarn test`.**

**What is the expected behavior?**

**Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.**
**Please provide your exact Jest configuration**

**Run `npx envinfo --preset jest` in your project directory and paste the
results here**
32 changes: 28 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

### Features

* `[expect]` Improve output format for mismatchedArgs in mock/spy calls.
([#5846](https://github.com/facebook/jest/pull/5846))
* `[jest-cli]` Add support for using `--coverage` in combination with watch
mode, `--onlyChanged`, `--findRelatedTests` and more
([#5601](https://github.com/facebook/jest/pull/5601))
* `[jest-jasmine2]` Adds error throwing and descriptive errors to `it`/ `test`
for invalid arguments. `[jest-circus]` Adds error throwing and descriptive
errors to `it`/ `test` for invalid arguments
Expand All @@ -16,16 +21,31 @@
([#5670](https://github.com/facebook/jest/pull/5670))
* `[expect]` Add inverse matchers (`expect.not.arrayContaining`, etc.,
[#5517](https://github.com/facebook/jest/pull/5517))
* `[expect]` `expect.extend` now also extends asymmetric matchers
([#5503](https://github.com/facebook/jest/pull/5503))
* `[jest-mock]` Update `spyOnProperty` to support spying on the prototype chain
([#5753](https://github.com/facebook/jest/pull/5753))
* `[jest-mock]` Add tracking of return values in the `mock` property
([#5738](https://github.com/facebook/jest/issues/5738))
([#5752](https://github.com/facebook/jest/pull/5752))
* `[jest-mock]` Add tracking of thrown errors in the `mock` property
([#5764](https://github.com/facebook/jest/pull/5764))
* `[expect]`Add nthCalledWith spy matcher
([#5605](https://github.com/facebook/jest/pull/5605))
* `[jest-cli]` Add `isSerial` property that runners can expose to specify that
they can not run in parallel
[#5706](https://github.com/facebook/jest/pull/5706)
([#5706](https://github.com/facebook/jest/pull/5706))
* `[expect]` Add `.toBeCalledTimes` and `toHaveBeenNthCalledWith` aliases
([#5826](https://github.com/facebook/jest/pull/5826))
* `[jest-cli]` Interactive Snapshot Mode improvements
([#5864](https://github.com/facebook/jest/pull/5864))

### Fixes

* `[jest-runner]` Assign `process.env.JEST_WORKER_ID="1"` when in runInBand mode
([#5860](https://github.com/facebook/jest/pull/5860))
* `[jest-cli]` Add descriptive error message when trying to use
`globalSetup`/`globalTeardown` file that doesn't export a function.
([#5835](https://github.com/facebook/jest/pull/5835))
* `[expect]` Do not rely on `instanceof RegExp`, since it will not work for
RegExps created inside of a different VM
([#5729](https://github.com/facebook/jest/pull/5729))
Expand All @@ -45,11 +65,15 @@
([#5702](https://github.com/facebook/jest/pull/5702))
* `[jest-mock]` Prevent `mockRejectedValue` from causing unhandled rejection
([#5720](https://github.com/facebook/jest/pull/5720))
* `[pretty-format]` Handle React fragments better
([#5816](https://github.com/facebook/jest/pull/5816))

### Chore & Maintenance

* `[#5858]` Run Prettier on compiled output
([#5858](https://github.com/facebook/jest/pull/3497))
* `[#5708]` Add fileChange hook for plugins
([#5648](https://github.com/facebook/jest/pull/5708))
([#5708](https://github.com/facebook/jest/pull/5708))
* `[docs]` Add docs on using `jest.mock(...)`
([#5648](https://github.com/facebook/jest/pull/5648))
* `[docs]` Mention Jest Puppeteer Preset
Expand Down Expand Up @@ -128,7 +152,7 @@
* `[docs]` Add a documentation note for project `displayName` configuration
([#5600](https://github.com/facebook/jest/pull/5600))

# Chore & Maintenance
### Chore & Maintenance

* `[docs]` Update automatic mocks documentation
([#5630](https://github.com/facebook/jest/pull/5630))
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ _Before_ submitting a pull request, please make sure the following is done…
5. If you've changed APIs, update the documentation.

6. Ensure the test suite passes via `yarn test`. To run the test suite you may
need to install Mercurial (`hg`). On macOS, this can be done using
[homebrew](http://brew.sh/): `brew install hg`.
need to install [Mercurial](https://www.mercurial-scm.org/) (`hg`). On
macOS, this can be done using [homebrew](http://brew.sh/):
`brew install hg`.

```sh
brew install hg # maybe
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Travis Build Status](https://travis-ci.org/facebook/jest.svg?branch=master)](https://travis-ci.org/facebook/jest)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/8n38o44k585hhvhd/branch/master?svg=true)](https://ci.appveyor.com/project/Daniel15/jest/branch/master)
[![npm version](https://badge.fury.io/js/jest.svg)](http://badge.fury.io/js/jest)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

🃏 Delightful JavaScript Testing

Expand Down
4 changes: 4 additions & 0 deletions crowdin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ files:
'vi': 'vi'
'zh-CN': 'zh-Hans'
'zh-TW': 'zh-Hant'
-
source: '/website/versioned_docs/**/*.md'
translation: '/website/translated_docs/%locale%/**/%original_file_name%'
languages_mapping: *anchor
-
source: '/website/i18n/en.json'
translation: '/website/i18n/%locale%.json'
Expand Down
8 changes: 3 additions & 5 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ commit. Behaves similarly to `--onlyChanged`.

### `--changedSince`

##### available in Jest **22.2.0+**

Runs tests related the changes since the provided branch. If the current branch
has diverged from the given branch, then only changes made locally will be
tested. Behaves similarly to `--onlyChanged`.
Expand All @@ -144,8 +142,6 @@ fail the test and require Jest to be run with `--updateSnapshot`.

### `--clearCache`

##### available in Jest **22.0.0+**

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
Expand Down Expand Up @@ -189,7 +185,9 @@ Alias: `-e`. Use this flag to show full diffs and errors instead of a patch.

Find and run the tests that cover a space separated list of source files that
were passed in as arguments. Useful for pre-commit hook integration to run the
minimal amount of tests necessary.
minimal amount of tests necessary. Can be used together with `--coverage` to
include a test coverage for the source files, no duplicate
`--collectCoverageFrom` arguments needed.

### `--forceExit`

Expand Down
32 changes: 8 additions & 24 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ Jest attempts to scan your dependency tree once (up-front) and cache it in order
to ease some of the filesystem raking that needs to happen while running tests.
This config option lets you customize where Jest stores that cache data on disk.

### `clearMocks` [boolean]

Default: `false`

Automatically clear mock calls and instances between every test. Equivalent to
calling `jest.clearAllMocks()` between each test. This does not remove any mock
implementation that may have been provided.

### `collectCoverage` [boolean]

Default: `false`
Expand Down Expand Up @@ -494,20 +502,10 @@ _Note: When using multi project runner, it's recommended to add a `displayName`
for each project. This will show the `displayName` of a project next to its
tests._

### `clearMocks` [boolean]

Default: `false`

Automatically clear mock calls and instances between every test. Equivalent to
calling `jest.clearAllMocks()` between each test. This does not remove any mock
implementation that may have been provided.

### `reporters` [array<moduleName | [moduleName, options]>]

Default: `undefined`

##### available in Jest **20.0.0+**

Use this configuration option to add custom reporters to Jest. A custom reporter
is a class that implements `onRunStart`, `onTestStart`, `onTestResult`,
`onRunComplete` methods that will be called when any of those events occurs.
Expand Down Expand Up @@ -606,8 +604,6 @@ programmatically using [`jest.resetModules()`](#jest-resetmodules).

Default: `undefined`

##### available in Jest **20.0.0+**

This option allows the use of a custom resolver. This resolver must be a node
module that exports a function expecting a string as the first argument for the
path to resolve and an object with the following structure as the second
Expand Down Expand Up @@ -677,8 +673,6 @@ where you may want to have multiple roots within one project, for example

### `runner` [string]

##### available in Jest **21.0.0+**

Default: `"jest-runner"`

This option allows you to use a custom runner instead of Jest's default test
Expand Down Expand Up @@ -816,8 +810,6 @@ you can use the `node` option to use a node-like environment instead.
If some tests require another environment, you can add a `@jest-environment`
docblock.

##### available in Jest **20.0.0+**

```js
/**
* @jest-environment jsdom
Expand All @@ -835,8 +827,6 @@ environment. The module must export a class with `setup`, `teardown` and
suites by assigning them to `this.global` object &ndash; this will make them
available in your test suites as global variables.

##### available in Jest **22.0.0+**

_Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown
in their own TestEnvironment._

Expand Down Expand Up @@ -880,8 +870,6 @@ beforeAll(() => {

### `testEnvironmentOptions` [Object]

##### available in Jest **22.0.0+**

Default: `{}`

Test environment options that will be passed to the `testEnvironment`. The
Expand All @@ -891,8 +879,6 @@ given to [jsdom](https://github.com/tmpvar/jsdom) such as

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

##### available in Jest **19.0.0+**

(default: `[ '**/__tests__/**/*.js?(x)', '**/?(*.)+(spec|test).js?(x)' ]`)

The glob patterns Jest uses to detect test files. By default it looks for `.js`
Expand Down Expand Up @@ -1110,8 +1096,6 @@ errors will also still be shown on the bottom after execution.

Default: `[]`

##### available in Jest **21.0.0+**

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.
Expand Down
2 changes: 1 addition & 1 deletion docs/Es6ClassMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class, but does not provide a way to spy on calls.
For the contrived example, the mock might look like this:

```javascript
// __mocks/sound-player.js
// __mocks__/sound-player.js
export default class SoundPlayer {
constructor() {
console.log('Mock SoundPlayer: constructor was called');
Expand Down
22 changes: 13 additions & 9 deletions docs/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ expect.extend({
test('even and odd numbers', () => {
expect(100).toBeDivisibleBy(2);
expect(101).not.toBeDivisibleBy(2);
expect({apples: 6, bananas: 3}).toEqual({
apples: expect.toBeDivisibleBy(2),
bananas: expect.not.toBeDivisibleBy(2),
});
});
```

Expand Down Expand Up @@ -451,8 +455,6 @@ test('the best flavor is not coconut', () => {

### `.resolves`

##### available in Jest **20.0.0+**

Use `resolves` to unwrap the value of a fulfilled promise so any other matcher
can be chained. If the promise is rejected the assertion fails.

Expand Down Expand Up @@ -481,8 +483,6 @@ test('resolves to lemon', async () => {

### `.rejects`

##### available in Jest **20.0.0+**

Use `.rejects` to unwrap the reason of a rejected promise so any other matcher
can be chained. If the promise is fulfilled the assertion fails.

Expand Down Expand Up @@ -567,6 +567,8 @@ describe('drinkAll', () => {

### `.toHaveBeenCalledTimes(number)`

Also under the alias: `.toBeCalledTimes(number)`

Use `.toHaveBeenCalledTimes` to ensure that a mock function got called exact
number of times.

Expand Down Expand Up @@ -622,10 +624,12 @@ test('applying to all flavors does mango last', () => {
});
```

### `.nthCalledWith(nthCall, arg1, arg2, ....)`
### `.toHaveBeenNthCalledWith(nthCall, arg1, arg2, ....)`

Also under the alias: `.nthCalledWith(arg1, arg2, ...)`

If you have a mock function, you can use `.nthCalledWith` to test what arguments
it was nth called with. For example, let's say you have a
If you have a mock function, you can use `.toHaveBeenNthCalledWith` to test what
arguments it was nth called with. For example, let's say you have a
`drinkEach(drink, Array<flavor>)` function that applies `f` to a bunch of
flavors, and you want to ensure that when you call it, the first flavor it
operates on is `'lemon'` and the second one is `'octopus'`. You can write:
Expand All @@ -636,8 +640,8 @@ Note that, nth argument must be positive integer starting from 1.
test('drinkEach drinks each drink', () => {
const drink = jest.fn();
drinkEach(drink, ['lemon', 'octopus']);
expect(drink).nthCalledWith(1, 'lemon');
expect(drink).nthCalledWith(2, 'octopus');
expect(drink).toHaveBeenNthCalledWith(1, 'lemon');
expect(drink).toHaveBeenNthCalledWith(2, 'octopus');
});
```

Expand Down
6 changes: 0 additions & 6 deletions docs/JestObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,6 @@ Returns the `jest` object for chaining.

### `jest.restoreAllMocks()`

##### available in Jest **21.1.0+**

Restores all mocks back to their original value. Equivalent to calling
`.mockRestore` on every mocked function. Beware that `jest.restoreAllMocks()`
only works when mock was created with `jest.spyOn`; other mocks will require you
Expand Down Expand Up @@ -464,8 +462,6 @@ Returns the `jest` object for chaining.

### `jest.spyOn(object, methodName)`

##### available in Jest **19.0.0+**

Creates a mock function similar to `jest.fn` but also tracks calls to
`object[methodName]`. Returns a Jest mock function.

Expand Down Expand Up @@ -506,8 +502,6 @@ test('plays video', () => {

### `jest.spyOn(object, methodName, accessType?)`

##### 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.
Expand Down
Loading

0 comments on commit 78afdd1

Please sign in to comment.