Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jestjs/jest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v27.5.0
Choose a base ref
...
head repository: jestjs/jest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v27.5.1
Choose a head ref

Commits on Feb 5, 2022

  1. Copy the full SHA
    a8b9444 View commit details
  2. Copy the full SHA
    eaeb78d View commit details
  3. chore: update snapshot

    SimenB committed Feb 5, 2022
    Copy the full SHA
    9bcd565 View commit details
  4. Copy the full SHA
    5f63582 View commit details
  5. Copy the full SHA
    f2f578f View commit details

Commits on Feb 6, 2022

  1. Copy the full SHA
    94a6752 View commit details
  2. Copy the full SHA
    5a95898 View commit details
  3. Copy the full SHA
    dd29978 View commit details
  4. Copy the full SHA
    e0f3d16 View commit details
  5. Copy the full SHA
    47c7a5b View commit details

Commits on Feb 7, 2022

  1. Copy the full SHA
    eace5f3 View commit details
  2. Copy the full SHA
    a9b7e8a View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3a7e1c9 View commit details
  4. Copy the full SHA
    932f78e View commit details
  5. Copy the full SHA
    bc1c884 View commit details
  6. Copy the full SHA
    7aadc37 View commit details
  7. Copy the full SHA
    92f3279 View commit details
  8. Copy the full SHA
    7400207 View commit details
  9. chore: run prettier

    SimenB committed Feb 7, 2022
    Copy the full SHA
    762b9b7 View commit details
  10. Copy the full SHA
    201901f View commit details
  11. Copy the full SHA
    1596aab View commit details

Commits on Feb 8, 2022

  1. chore: remove @babel/plugin-proposal-class-properties

    It is included in `@babel/preset-env`
    SimenB committed Feb 8, 2022
    Copy the full SHA
    dfbe71d View commit details
  2. Copy the full SHA
    506a062 View commit details
  3. Copy the full SHA
    55caeb7 View commit details
  4. Copy the full SHA
    0e3013a View commit details
  5. Copy the full SHA
    a838175 View commit details
  6. v27.5.1

    SimenB committed Feb 8, 2022
    Copy the full SHA
    67c1aa2 View commit details
Showing 460 changed files with 12,525 additions and 3,401 deletions.
8 changes: 3 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ aliases:
app-dir: ~/jest

orbs:
node: circleci/node@4.7.0
node: circleci/node@5.0.0

jobs:
test-node:
@@ -28,7 +28,6 @@ jobs:
- checkout
- node/install:
node-version: << parameters.node-version >>
install-npm: false
- node/install-packages: *install
- when:
condition: << parameters.partial >>
@@ -49,8 +48,7 @@ jobs:
steps:
- checkout
- node/install:
node-version: '14'
install-npm: false
node-version: lts/*
- node/install-packages: *install
- run:
command: JEST_JASMINE=1 yarn test-ci-partial && JEST_JASMINE=1 yarn test-leak
@@ -64,7 +62,7 @@ workflows:
- test-node:
matrix:
parameters:
node-version: ['14']
node-version: ['lts/*']
- test-node:
name: test-node-partial-<< matrix.node-version >>
partial: true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
bin/
flow-typed/**
packages/*/build/**
packages/*/dist/**
packages/jest-diff/src/cleanupSemantic.ts
website/.docusaurus
website/blog
32 changes: 25 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -5,15 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/

const {sync: readPkg} = require('read-pkg');
const {getPackages} = require('./scripts/buildUtils');

const internalPackages = getPackages()
.map(packageDir => {
const pkg = readPkg({cwd: packageDir});

return pkg.name;
})
.map(({pkg}) => pkg.name)
.sort();

module.exports = {
@@ -160,6 +155,17 @@ module.exports = {
'sort-keys': 'off',
},
},
// snapshots in examples plus inline snapshots need to keep backtick
{
files: ['*.md', 'e2e/custom-inline-snapshot-matchers/__tests__/*'],
rules: {
quotes: [
'error',
'single',
{allowTemplateLiterals: true, avoidEscape: true},
],
},
},
{
files: ['website/**/*'],
rules: {
@@ -185,6 +191,18 @@ module.exports = {
files: 'packages/**/*.ts',
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'error',
'import/no-anonymous-default-export': [
'error',
{
allowAnonymousClass: false,
allowAnonymousFunction: false,
allowArray: false,
allowArrowFunction: false,
allowCallExpression: false,
allowLiteral: false,
allowObject: true,
},
],
},
},
{
@@ -462,7 +480,7 @@ module.exports = {
quotes: [
'error',
'single',
{allowTemplateLiterals: true, avoidEscape: true},
{allowTemplateLiterals: false, avoidEscape: true},
],
radix: 'warn',
'require-jsdoc': 'off',
8 changes: 4 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ jobs:

- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: lts/*
cache: yarn

- name: Validate cache
@@ -46,7 +46,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12.x
node-version: lts/*
cache: yarn
- name: install
run: yarn --immutable
@@ -114,10 +114,10 @@ jobs:
git config --global core.symlinks true
if: runner.os == 'Windows'
- uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js LTS
uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: lts/*
cache: yarn
- name: install
run: yarn --immutable
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
/node_modules

/packages/*/build/
/packages/*/dist/
/packages/*/coverage/
/packages/*/node_modules/

@@ -40,6 +41,7 @@ junit.xml
package-lock.json

*.tsbuildinfo
api-extractor.json

# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored but nested for e2e directories
**/.yarn/*
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,24 @@

### Performance

## 27.5.1

### Features

- `[jest-config]` Support comments in JSON config file ([#12316](https://github.com/facebook/jest/pull/12316))
- `[pretty-format]` Expose `ConvertAnsi` plugin ([#12308](https://github.com/facebook/jest/pull/12308))

### Fixes

- `[expect]` Add type definitions for asymmetric `closeTo` matcher ([#12304](https://github.com/facebook/jest/pull/12304))
- `[jest-cli]` Load binary via exported API ([#12315](https://github.com/facebook/jest/pull/12315))
- `[jest-config]` Replace `jsonlint` with `parse-json` ([#12316](https://github.com/facebook/jest/pull/12316))
- `[jest-repl]` Make module importable ([#12311](https://github.com/facebook/jest/pull/12311) & [#12315](https://github.com/facebook/jest/pull/12315))

### Chore & Maintenance

- `[*]` Avoid anonymous default exports ([#12313](https://github.com/facebook/jest/pull/12313))

## 27.5.0

### Features
1 change: 0 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -38,7 +38,6 @@ module.exports = {
],
plugins: [
['@babel/plugin-transform-modules-commonjs', {allowTopLevelThis: true}],
'@babel/plugin-proposal-class-properties',
require.resolve('./scripts/babel-plugin-jest-require-outside-vm'),
],
presets: [
2 changes: 2 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
@@ -1262,6 +1262,8 @@ This option allows the use of a custom results processor. This processor must be
}
```

`testResultsProcessor` and `reporters` are very similar to each other. One difference is that a test result processor only gets called after all tests finished. Whereas a reporter has the ability to receive test results after individual tests and/or test suites are finished.

### `testRunner` \[string]

Default: `jest-circus/runner`
2 changes: 1 addition & 1 deletion docs/ExpectAPI.md
Original file line number Diff line number Diff line change
@@ -751,7 +751,7 @@ test('drinkEach drinks each drink', () => {

Also under the alias: `.toBeCalledWith()`

Use `.toHaveBeenCalledWith` to ensure that a mock function was called with specific arguments.
Use `.toHaveBeenCalledWith` to ensure that a mock function was called with specific arguments. The arguments are checked with the same algorithm that `.toEqual` uses.

For example, let's say that you can register a beverage with a `register` function, and `applyToAll(f)` should apply the function `f` to all registered beverages. To make sure this works, you could write:

8 changes: 7 additions & 1 deletion docs/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ Jest can be used in projects that use [webpack](https://webpack.js.org/) to mana

Jest can be used in projects that use [parcel-bundler](https://parceljs.org/) to manage assets, styles, and compilation similar to webpack. Parcel requires zero configuration. Refer to the official [docs](https://parceljs.org/docs/) to get started.

### Using TypeScript
### Using TypeScript via Babel

Jest supports TypeScript, via Babel. First, make sure you followed the instructions on [using Babel](#using-babel) above. Next, install the `@babel/preset-typescript` via `yarn`:

@@ -169,6 +169,12 @@ module.exports = {

However, there are some [caveats](https://babeljs.io/docs/en/babel-plugin-transform-typescript#caveats) to using TypeScript with Babel. Because TypeScript support in Babel is purely transpilation, Jest will not type-check your tests as they are run. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest) instead, or just run the TypeScript compiler [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html) separately (or as part of your build process).

### Using TypeScript via ts-jest

[ts-jest](https://github.com/kulshekhar/ts-jest) is a TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript.

### Using TypeScript: type definitions

You may also want to install the [`@types/jest`](https://www.npmjs.com/package/@types/jest) module for the version of Jest you're using. This will help provide full typing when writing your tests with TypeScript.

> For `@types/*` modules it's recommended to try to match the version of the associated module. For example, if you are using `26.4.0` of `jest` then using `26.4.x` of `@types/jest` is ideal. In general, try to match the major (`26`) and minor (`4`) version as closely as possible.
2 changes: 2 additions & 0 deletions docs/TimerMocks.md
Original file line number Diff line number Diff line change
@@ -53,6 +53,8 @@ test('do something with real timers', () => {
});
```

Currently, two implementations of the fake timers are included - `modern` and `legacy`, where `modern` is the default one. See [configuration](Configuration.md#timers-string) for how to configure it.

## Run All Timers

Another test we might want to write for this module is one that asserts that the callback is called after 1 second. To do this, we're going to use Jest's timer control APIs to fast-forward time right in the middle of the test:
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/asyncAndCallback.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`errors when a test both returns a promise and takes a callback 1`] = `
FAIL __tests__/promise-and-callback.test.js
"FAIL __tests__/promise-and-callback.test.js
✕ promise-returning test with callback
✕ async test with callback
✕ test done before return value
@@ -49,5 +49,5 @@ FAIL __tests__/promise-and-callback.test.js
22 |
23 | return 'foobar';
at Object.it (__tests__/promise-and-callback.test.js:20:1)
at Object.it (__tests__/promise-and-callback.test.js:20:1)"
`;
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/beforeAllFiltered.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Correct BeforeAll run ensures the BeforeAll of ignored suite is not run 1`] = `
console.log
" console.log
beforeAll 1
at log (__tests__/beforeAllFiltered.test.js:10:13)
@@ -25,5 +25,5 @@ exports[`Correct BeforeAll run ensures the BeforeAll of ignored suite is not run
afterAll 1
at log (__tests__/beforeAllFiltered.test.js:19:13)
"
`;
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/beforeEachQueue.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Correct beforeEach order ensures the correct order for beforeEach 1`] = `
console.log
" console.log
BeforeEach
at Object.log (__tests__/beforeEachQueue.test.js:10:13)
@@ -25,5 +25,5 @@ exports[`Correct beforeEach order ensures the correct order for beforeEach 1`] =
It Bar
at Object.log (__tests__/beforeEachQueue.test.js:22:13)
"
`;
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/callDoneTwice.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`\`done()\` should not be called more than once 1`] = `
FAIL __tests__/index.test.js
"FAIL __tests__/index.test.js
\`done()\` called more than once › should fail
Expected done to be called once, but it was called multiple times.
@@ -85,5 +85,5 @@ FAIL __tests__/index.test.js
61 |
62 | it('should fail', () => {
at done (__tests__/index.test.js:59:5)
at done (__tests__/index.test.js:59:5)"
`;
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/chaiAssertionLibrary.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`chai assertion errors should display properly 1`] = `
FAIL __tests__/chai_assertion.js
"FAIL __tests__/chai_assertion.js
● chai.js assertion library test › expect
assert.strictEqual(received, expected)
@@ -90,5 +90,5 @@ FAIL __tests__/chai_assertion.js
26 | });
27 |
at Object.strictEqual (__tests__/chai_assertion.js:24:17)
at Object.strictEqual (__tests__/chai_assertion.js:24:17)"
`;
8 changes: 4 additions & 4 deletions e2e/__tests__/__snapshots__/circularInequality.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`handles circular inequality properly 1`] = `
FAIL __tests__/test-1.js
"FAIL __tests__/test-1.js
● test
expect(received).toEqual(expected) // deep equality
@@ -41,13 +41,13 @@ FAIL __tests__/test-2.js
| ^
6 | });
at Object.toEqual (__tests__/test-2.js:5:15)
at Object.toEqual (__tests__/test-2.js:5:15)"
`;

exports[`handles circular inequality properly 2`] = `
Test Suites: 2 failed, 2 total
"Test Suites: 2 failed, 2 total
Tests: 2 failed, 2 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites.
Ran all test suites."
`;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`defining tests and hooks asynchronously throws 1`] = `
FAIL __tests__/asyncDefinition.test.js
"FAIL __tests__/asyncDefinition.test.js
● Test suite failed to run
@@ -61,5 +61,5 @@ FAIL __tests__/asyncDefinition.test.js
21 |
at eventHandler (../../packages/jest-circus/build/eventHandler.js:158:11)
at afterAll (__tests__/asyncDefinition.test.js:19:3)
at afterAll (__tests__/asyncDefinition.test.js:19:3)"
`;
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CLI accepts exact file names if matchers matched 1`] = `
PASS foo/bar.spec.js
"PASS foo/bar.spec.js
✓ foo
Force exiting Jest: Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?
Force exiting Jest: Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?"
`;

exports[`CLI accepts exact file names if matchers matched 2`] = `
Test Suites: 1 passed, 1 total
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites matching /.\\/foo\\/bar.spec.js/i.
Ran all test suites matching /.\\/foo\\/bar.spec.js/i."
`;
Loading