Repository navigation
Upgrade Jest to version 24 (breaking changes) #13922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
242e873
0935a4b
62ededb
4b59308
87051ee
2cbb31a
88c8cd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import 'expect-puppeteer'; | ||
| import { get } from 'lodash'; | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,14 @@ | ||
| module.exports = { | ||
| ...require( '@wordpress/scripts/config/jest-e2e.config' ), | ||
| setupTestFrameworkScriptFile: '<rootDir>/config/setup-test-framework.js', | ||
| setupFiles: [ | ||
| '<rootDir>/config/gutenberg-phase.js', | ||
| ], | ||
| setupFilesAfterEnv: [ | ||
| '<rootDir>/config/setup-test-framework.js', | ||
| 'expect-puppeteer', | ||
| ], | ||
| transformIgnorePatterns: [ | ||
| 'node_modules', | ||
| 'scripts/config/puppeteer.config.js', | ||
| ], | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,11 +21,10 @@ | |||||
| "@wordpress/e2e-test-utils": "file:../e2e-test-utils", | ||||||
| "@wordpress/jest-console": "file:../jest-console", | ||||||
| "@wordpress/scripts": "file:../scripts", | ||||||
| "expect-puppeteer": "^3.2.0", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? It's still referenced as an import:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it because, via jestjs/jest#7119 , we can trust it to be provided through the preset from
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like Jest doesn't merge {
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/private/var/folders/8t/0144m_sn3_q5x_cjrfflbkxm0000gn/T/jest_dx",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"cwd": "/Users/gziolo/PhpstormProjects/gutenberg",
"dependencyExtractor": null,
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"filter": null,
"forceCoverageMatch": [],
"globalSetup": "/Users/gziolo/PhpstormProjects/gutenberg/node_modules/jest-environment-puppeteer/setup.js",
"globalTeardown": "/Users/gziolo/PhpstormProjects/gutenberg/node_modules/jest-environment-puppeteer/teardown.js",
"globals": {},
"haste": {
"computeSha1": false,
"providesModuleNodeModules": []
},
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"json",
"jsx",
"ts",
"tsx",
"node"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": [],
"name": "8d30620c7b75cfd5f4f78d9ee46d32f5",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
"resolver": null,
"restoreMocks": false,
"rootDir": "/Users/gziolo/PhpstormProjects/gutenberg/packages/e2e-tests",
"roots": [
"/Users/gziolo/PhpstormProjects/gutenberg/packages/e2e-tests"
],
"runner": "jest-runner",
"setupFiles": [
"/Users/gziolo/PhpstormProjects/gutenberg/packages/e2e-tests/config/gutenberg-phase.js"
],
"setupFilesAfterEnv": [
"/Users/gziolo/PhpstormProjects/gutenberg/packages/e2e-tests/config/setup-test-framework.js"
],
"skipFilter": false,
"snapshotSerializers": [],
"testEnvironment": "/Users/gziolo/PhpstormProjects/gutenberg/node_modules/jest-environment-puppeteer/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.js",
"**/?(*.)(spec|test).js",
"**/test/*.js"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": [],
"testRunner": "/Users/gziolo/PhpstormProjects/gutenberg/node_modules/jest-jasmine2/build/index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\\.[jt]sx?$",
"/Users/gziolo/PhpstormProjects/gutenberg/node_modules/babel-jest/build/index.js"
]
],
"transformIgnorePatterns": [
"node_modules",
"scripts/config/puppeteer.config.js"
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": 0,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": null,
"coverageDirectory": "/Users/gziolo/PhpstormProjects/gutenberg/packages/e2e-tests/coverage",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"coverageThreshold": null,
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"expand": false,
"filter": null,
"globalSetup": "/Users/gziolo/PhpstormProjects/gutenberg/node_modules/jest-environment-puppeteer/setup.js",
"globalTeardown": "/Users/gziolo/PhpstormProjects/gutenberg/node_modules/jest-environment-puppeteer/teardown.js",
"listTests": false,
"maxConcurrency": 5,
"maxWorkers": 1,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "failure-change",
"passWithNoTests": false,
"projects": null,
"rootDir": "/Users/gziolo/PhpstormProjects/gutenberg/packages/e2e-tests",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": null,
"watch": false,
"watchman": true
},
"version": "24.1.0"
}I will add
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm still not sure whether we should include it in the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This specific reference is a bit unique than a traditional
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the record, it's referenced in the config file and it repeats what was already provided in the preset:
I think I will add it as a dependency just for consistency. It would be nicer if we could just include additional entries rather than repeat what was already listed in the preset.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in #14212. |
||||||
| "lodash": "^4.17.11" | ||||||
| }, | ||||||
| "peerDependencies": { | ||||||
| "jest": ">=23", | ||||||
| "jest": ">=24", | ||||||
| "puppeteer": ">=1.6" | ||||||
| }, | ||||||
| "publishConfig": { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,21 +27,11 @@ npm install @wordpress/jest-preset-default --save-dev | |
| * `moduleNameMapper` - all `css` and `scss` files containing CSS styles will be stubbed out. | ||
| * `modulePaths` - the root dir of the project is used as a location to search when resolving modules. | ||
| * `setupFiles` - runs code before each test which sets up global variables required in the testing environment. | ||
| * `setupTestFrameworkScriptFile` - runs code which adds improved support for `Console` object and `React` components to the testing framework before each test. | ||
| * `setupFilesAfterEnv` - runs code which adds improved support for `Console` object and `React` components to the testing framework before each test. | ||
| * `snapshotSerializers` - makes it possible to use snapshot tests on `Enzyme` wrappers. | ||
| * `testMatch`- includes `/test/` subfolder in the glob patterns Jest uses to detect test files. It detects only test files containing `.js` extension. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| * `timers` - use of [fake timers](https://jestjs.io/docs/en/timer-mocks.html) for functions such as `setTimeout` is enabled. | ||
| * `transform` - adds support for [PEG.js]( https://github.com/pegjs/pegjs#javascript-api) transformed necessary for WordPress blocks. It also keeps the default [babel-jest](https://github.com/facebook/jest/tree/master/packages/babel-jest) transformer. | ||
| * `transform` - keeps the default [babel-jest](https://github.com/facebook/jest/tree/master/packages/babel-jest) transformer. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We removed |
||
| * `verbose` - each individual test won't be reported during the run. | ||
|
|
||
| #### Overriding `setupTestFrameworkScriptFile` | ||
|
|
||
| It is also possible to override the script that runs some code to configure or set up the testing framework before each test. To do so you will need to create `setup-test-framework.js` inside your project with the following content: | ||
|
|
||
| ```js | ||
| // You can still load the default script provided by this setup | ||
| import '@wordpress/jest-preset-default'; | ||
|
|
||
| // Your code goes here | ||
| ``` | ||
|
|
||
| <br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p> | ||
Uh oh!
There was an error while loading. Please reload this page.