Skip to content

Commit

Permalink
Scripts: Upgrade Jest to the new major version (26.x) (#27956)
Browse files Browse the repository at this point in the history
* Scripts: Update Jest to v26

* Update RN tests for isUrl method

* Docs: Add changelog entries for packages with Jest version change
  • Loading branch information
gziolo committed Jan 3, 2021
1 parent 351b76f commit 2bce694
Show file tree
Hide file tree
Showing 22 changed files with 2,796 additions and 4,318 deletions.
6,900 changes: 2,713 additions & 4,187 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"@babel/plugin-syntax-jsx": "7.12.1",
"@babel/runtime-corejs3": "7.12.5",
"@babel/traverse": "7.12.9",
"@jest/types": "25.3.0",
"@octokit/rest": "16.26.0",
"@octokit/webhooks": "7.1.0",
"@storybook/addon-a11y": "6.1.11",
Expand All @@ -95,7 +94,7 @@
"@storybook/addon-storysource": "6.1.11",
"@storybook/addon-viewport": "6.1.11",
"@storybook/react": "6.1.11",
"@testing-library/react": "10.0.2",
"@testing-library/react": "11.2.2",
"@types/classnames": "2.2.10",
"@types/eslint": "6.8.0",
"@types/estree": "0.0.44",
Expand Down Expand Up @@ -135,7 +134,7 @@
"@wordpress/project-management-automation": "file:packages/project-management-automation",
"@wordpress/scripts": "file:packages/scripts",
"appium": "1.18.3",
"babel-jest": "25.3.0",
"babel-jest": "26.6.3",
"babel-loader": "8.1.0",
"babel-plugin-emotion": "10.0.33",
"babel-plugin-inline-json-import": "0.3.2",
Expand All @@ -160,12 +159,12 @@
"glob": "7.1.2",
"husky": "3.0.5",
"inquirer": "7.1.0",
"jest": "25.5.4",
"jest": "26.6.3",
"jest-emotion": "10.0.32",
"jest-junit": "10.0.0",
"jest-junit": "11.0.0",
"jest-serializer-enzyme": "1.0.0",
"jest-watch-typeahead": "0.6.0",
"jsdom": "15.2.1",
"jest-watch-typeahead": "0.6.1",
"jsdom": "16.4.0",
"lerna": "3.18.2",
"lint-staged": "9.2.5",
"lodash": "4.17.19",
Expand Down
17 changes: 11 additions & 6 deletions packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ When creating a new package, you need to provide at least the following:
- API documentation, if applicable ([more info](#maintaining-api-documentation))
- `Code is Poetry` logo (`<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>`)
4. `CHANGELOG.md` file containing at least:

```
<!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/master/packages#maintaining-changelogs. -->
## Unreleased
## Unreleased
Initial release.
Initial release.
```

## Managing Dependencies
Expand Down Expand Up @@ -87,7 +88,7 @@ _Example:_
"check-node-version": "^3.1.1",
"cross-spawn": "^5.1.0",
"eslint": "^7.1.0",
- "jest": "^25.3.0",
- "jest": "^26.6.3",
"jest-puppeteer": "^4.4.0",
"minimist": "^1.2.0",
"npm-package-json-lint": "^3.6.0",
Expand All @@ -98,8 +99,9 @@ Next, you need to run `npm install` in the root of the project to ensure that `p
#### Updating Existing Dependencies

This is the most confusing part of working with [lerna] which causes a lot of hassles for contributors. The most successful strategy so far is to do the following:
1. First, remove the existing dependency as described in the previous section.
2. Next, add the same dependency back as described in the first section of this chapter. This time it wil get the latest version applied unless you enforce a different version explicitly.

1. First, remove the existing dependency as described in the previous section.
2. Next, add the same dependency back as described in the first section of this chapter. This time it wil get the latest version applied unless you enforce a different version explicitly.

### Development Dependencies

Expand Down Expand Up @@ -304,7 +306,10 @@ If your package includes a few files with side effects, you can list them instea
```json
{
"name": "package",
"sideEffects": [ "file-with-side-effects.js", "another-file-with-side-effects.js" ]
"sideEffects": [
"file-with-side-effects.js",
"another-file-with-side-effects.js"
]
}
```

Expand Down
18 changes: 4 additions & 14 deletions packages/components/src/sandbox/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import Sandbox from '../';
describe( 'Sandbox', () => {
const TestWrapper = () => {
const [ html, setHtml ] = useState(
'<iframe class="mock-iframe" src="https://super.embed"></iframe>'
// MuatationObserver implementation from JSDom does not work as intended
// with iframes so we need to ignore it for the time being.
'<script type="text/javascript">window.MutationObserver = null;</script>' +
'<iframe class="mock-iframe" src="https://super.embed"></iframe>'
);

const updateHtml = () => {
Expand All @@ -35,19 +38,6 @@ describe( 'Sandbox', () => {
);
};

beforeAll( () => {
// MuatationObserver implmentation from JSDom does not work as intended
// with iframes so we need to ignore it for the time being.
jest.spyOn(
global.MutationObserver.prototype,
'observe'
).mockImplementation( () => {} );
} );

afterAll( () => {
global.MutationObserver.prototype.mockReset();
} );

it( 'should rerender with new emdeded content if html prop changes', () => {
let result;
act( () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"url": "https://github.com/WordPress/gutenberg/issues"
},
"engines": {
"node": ">=8"
"node": ">=12"
},
"files": [
"build",
Expand All @@ -36,7 +36,7 @@
"node-fetch": "^2.6.0"
},
"peerDependencies": {
"jest": ">=24",
"jest": ">=26",
"puppeteer": ">=1.19.0"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"url": "https://github.com/WordPress/gutenberg/issues"
},
"engines": {
"node": ">=8"
"node": ">=12"
},
"dependencies": {
"@wordpress/e2e-test-utils": "file:../e2e-test-utils",
Expand All @@ -34,7 +34,7 @@
"uuid": "^8.3.0"
},
"peerDependencies": {
"jest": ">=24",
"jest": ">=26",
"puppeteer": ">=1.19.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-navigation/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { menuItemsQuery, computeCustomizedAttribute } from '../utils';

jest.mock( '../utils', () => {
const utils = require.requireActual( '../utils' );
const utils = jest.requireActual( '../utils' );
// Mock serializeProcessing to always return the callback for easier testing and less boilerplate.
utils.serializeProcessing = ( callback ) => callback;
return utils;
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-navigation/src/store/test/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { KIND, POST_TYPE, buildNavigationPostId } from '../utils';

// Mock createBlock to avoid creating block in test environment
jest.mock( '@wordpress/blocks', () => {
const blocks = require.requireActual( '@wordpress/blocks' );
const blocks = jest.requireActual( '@wordpress/blocks' );
let id = 0;

return {
Expand Down
18 changes: 11 additions & 7 deletions packages/jest-console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,43 @@

## Unreleased

### Breaking Changes

- The peer `jest` dependency has been updated from requiring `>=24` to requiring `>=26` (see [Breaking Changes](https://jestjs.io/blog/2020/05/05/jest-26), [#27956](https://github.com/WordPress/gutenberg/pull/27956)).

## 3.0.0 (2019-03-06)

### Breaking Changes

- Increased the recommended Jest dependency to version 24 ([#13922](https://github.com/WordPress/gutenberg/pull/13922).
- Increased the recommended Jest dependency to version 24 ([#13922](https://github.com/WordPress/gutenberg/pull/13922).

## 2.0.7 (2018-11-20)

## 2.0.5 (2018-09-30)

### Bug Fixes

- Captures and protects against unexpected console logging occurring during lifecycle.
- Captures and protects against unexpected console logging occurring during lifecycle.

## 2.0.0 (2018-07-12)

### Breaking Changes

- Add new API methods `toHaveInformed`, `toHaveInformedWith`, `toHaveLogged` and `toHaveLoggedWith` ([#137](https://github.com/WordPress/packages/pull/137)). If the code under test calls `console.log` or `console.info` it will fail, unless one of the newly introduced methods is explicitly used to verify it.
- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832))
- Add new API methods `toHaveInformed`, `toHaveInformedWith`, `toHaveLogged` and `toHaveLoggedWith` ([#137](https://github.com/WordPress/packages/pull/137)). If the code under test calls `console.log` or `console.info` it will fail, unless one of the newly introduced methods is explicitly used to verify it.
- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832))

### Internal

- Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805))
- Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805))

## 1.0.7 (2018-05-18)

### Polish

- Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119))
- Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119))

## 1.0.6 (2018-02-28)

### Polish

- Removed `package-lock.json` file, lockfiles for apps, not packages ([#88](https://github.com/WordPress/packages/pull/88))
- Removed `package-lock.json` file, lockfiles for apps, not packages ([#88](https://github.com/WordPress/packages/pull/88))
6 changes: 3 additions & 3 deletions packages/jest-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/WordPress/gutenberg/issues"
},
"engines": {
"node": ">=8"
"node": ">=12"
},
"files": [
"build",
Expand All @@ -31,11 +31,11 @@
"module": "build-module/index.js",
"dependencies": {
"@babel/runtime": "^7.12.5",
"jest-matcher-utils": "^25.3.0",
"jest-matcher-utils": "^26.6.2",
"lodash": "^4.17.19"
},
"peerDependencies": {
"jest": ">=24"
"jest": ">=26"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 4 additions & 0 deletions packages/jest-preset-default/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Breaking Changes

- The peer `jest` dependency has been updated from requiring `>=25` to requiring `>=26` (see [Breaking Changes](https://jestjs.io/blog/2020/05/05/jest-26), [#27956](https://github.com/WordPress/gutenberg/pull/27956)).

## 6.5.0 (2020-10-30)

### Enhancements
Expand Down
8 changes: 0 additions & 8 deletions packages/jest-preset-default/jest-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,4 @@ module.exports = {
'^.+\\.[jt]sx?$': require.resolve( 'babel-jest' ),
},
verbose: true,
reporters:
'TRAVIS' in process.env && 'CI' in process.env
? [
require.resolve(
'@wordpress/jest-preset-default/scripts/travis-fold-passes-reporter.js'
),
]
: undefined,
};
7 changes: 3 additions & 4 deletions packages/jest-preset-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"url": "https://github.com/WordPress/gutenberg/issues"
},
"engines": {
"node": ">=10"
"node": ">=12"
},
"files": [
"scripts",
Expand All @@ -31,15 +31,14 @@
],
"main": "index.js",
"dependencies": {
"@jest/reporters": "^25.3.0",
"@wordpress/jest-console": "file:../jest-console",
"babel-jest": "^25.3.0",
"babel-jest": "^26.6.3",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4"
},
"peerDependencies": {
"jest": ">=25"
"jest": ">=26"
},
"publishConfig": {
"access": "public"
Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions packages/jest-puppeteer-axe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

### Breaking Changes

- The peer `jest` dependency has been updated from requiring `>=24` to requiring `>=26` (see [Breaking Changes](https://jestjs.io/blog/2020/05/05/jest-26), [#27956](https://github.com/WordPress/gutenberg/pull/27956)).

### Breaking Changes

- Migrated `axe-puppeteer` to its new package [@axe-core/puppeteer](https://github.com/dequelabs/axe-core-npm/tree/develop/packages/puppeteer) that contains breaking changes.

## 1.1.0 (2019-05-21)
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-puppeteer-axe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"url": "https://github.com/WordPress/gutenberg/issues"
},
"engines": {
"node": ">=8"
"node": ">=12"
},
"files": [
"build",
Expand All @@ -35,7 +35,7 @@
"@babel/runtime": "^7.12.5"
},
"peerDependencies": {
"jest": ">=24",
"jest": ">=26",
"puppeteer": ">=1.19.0"
},
"publishConfig": {
Expand Down
4 changes: 4 additions & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Breaking Changes

- The peer `jest` dependency has been updated from requiring `>=25` to requiring `>=26` (see [Breaking Changes](https://jestjs.io/blog/2020/05/05/jest-26), [#27956](https://github.com/WordPress/gutenberg/pull/27956)).

## 12.6.0 (2020-12-17)

### Enhancements
Expand Down

0 comments on commit 2bce694

Please sign in to comment.