Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit b7de784

Browse files
gigituxoprsenadir
authored
Fix E2E tests (#6415)
* Fix E2E tests #6415 Fix E2E tests * Add full state in customer data and exclude it from details check * update webpack configuration * Revert change to combobox index * don't splitChunk frontend scripts * simplfy output folders * reduce minimum chunk size to 10kb * add all inner blocks for loading * better splitChunks * update translation code * wait for scripts * try sleeping * fix loading translation * fix tests for mini cart * simplfy po logic * automate loading chunks * rename webpack group file * rename block.json path * remove test * revert changes to webpack file * fix loading of chunks * revert changes to assets api as well * restore wp-env json configuration * restore .wp-env.json * address feedback * add comment * address comments * improve utils function * install puppeteer Co-authored-by: Thomas Roberts <[email protected]> Co-authored-by: Nadir Seghir <[email protected]>
1 parent 8344018 commit b7de784

15 files changed

+28686
-29734
lines changed

package-lock.json

Lines changed: 28548 additions & 29647 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@
6868
"storybook:deploy": "rimraf ./storybook/dist/* && npm run storybook:build && gh-pages -d ./storybook/dist",
6969
"test": "wp-scripts test-unit-js --config tests/js/jest.config.json",
7070
"test:debug": "ndb .",
71-
"test:e2e": "npm run wp-env:config && cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js",
72-
"test:e2e-dev": "npm run wp-env:config && cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --puppeteer-interactive",
73-
"test:e2e-dev-watch": "npm run wp-env:config && cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --watch --puppeteer-interactive",
74-
"test:e2e:update": "npm run wp-env:config && cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --updateSnapshot",
71+
"test:e2e": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e/config/jest-puppeteer.config.js NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js",
72+
"test:e2e-dev": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e/config/jest-puppeteer.config.js NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --puppeteer-interactive",
73+
"test:e2e-dev-watch": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e/config/jest-puppeteer.config.js NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --watch --puppeteer-interactive",
74+
"test:e2e:update": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e/config/jest-puppeteer.config.js NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --updateSnapshot",
7575
"test:help": "wp-scripts test-unit-js --help",
7676
"pretest:php": "npm run wp-env run composer 'install --no-interaction'",
7777
"test:performance": "npm run wp-env:config && cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.performance.config.js -- performance",
@@ -104,11 +104,11 @@
104104
"@testing-library/react": "12.1.5",
105105
"@testing-library/react-hooks": "7.0.2",
106106
"@testing-library/user-event": "13.5.0",
107-
"@types/jest-environment-puppeteer": "5.0.2",
108107
"@types/classnames": "2.3.0",
109108
"@types/dinero.js": "1.9.0",
110109
"@types/gtag.js": "0.0.10",
111110
"@types/jest": "27.4.1",
111+
"@types/jest-environment-puppeteer": "5.0.2",
112112
"@types/jquery": "3.5.14",
113113
"@types/lodash": "4.14.182",
114114
"@types/puppeteer": "5.4.6",
@@ -136,7 +136,7 @@
136136
"@wordpress/dependency-extraction-webpack-plugin": "3.2.1",
137137
"@wordpress/dom": "3.2.7",
138138
"@wordpress/e2e-test-utils": "7.4.0",
139-
"@wordpress/e2e-tests": "3.1.1",
139+
"@wordpress/e2e-tests": "4.3.0",
140140
"@wordpress/element": "4.0.4",
141141
"@wordpress/env": "4.5.0",
142142
"@wordpress/html-entities": "3.2.3",
@@ -174,7 +174,7 @@
174174
"glob-promise": "3.4.0",
175175
"husky": "2.4.1",
176176
"ignore-loader": "0.1.2",
177-
"jest-circus": "27.2.4",
177+
"jest-circus": "27.5.1",
178178
"jest-environment-puppeteer": "6.0.3",
179179
"jest-fetch-mock": "3.0.3",
180180
"jest-html-reporters": "2.1.7",
@@ -190,6 +190,7 @@
190190
"prettier": "npm:[email protected]",
191191
"progress-bar-webpack-plugin": "2.1.0",
192192
"promptly": "3.2.0",
193+
"puppeteer": "13.7.0",
193194
"react-docgen": "5.4.0",
194195
"react-test-renderer": "17.0.2",
195196
"request-promise": "4.2.6",

tests/e2e/config/default.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"addressfirstline": "123 Main Road",
4343
"addresssecondline": "Unit 23",
4444
"city": "San Francisco",
45-
"state": "CA",
45+
"state": "California",
4646
"postcode": "94107",
4747
"phone": "123456789",
4848
"email": "[email protected]"
@@ -55,7 +55,7 @@
5555
"addressfirstline": "123 Main Avenue",
5656
"addresssecondline": "Unit 42",
5757
"city": "Los Angeles",
58-
"state": "CA",
58+
"state": "California",
5959
"postcode": "90010",
6060
"phone": "987654321"
6161
}

tests/e2e/config/environment.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,37 @@ class E2EEnvironment extends PuppeteerEnvironment {
2323
}
2424
}
2525

26+
// This code is helpful for tracing every test that is executed.
27+
// You should use this code if your test fails, but Jest doesn't give you a significant error, and you need to debug.
28+
// async handleTestEvent( event ) {
29+
// const ignoredEvents = [
30+
// 'setup',
31+
// 'add_hook',
32+
// 'start_describe_definition',
33+
// 'add_test',
34+
// 'finish_describe_definition',
35+
// 'run_start',
36+
// 'run_describe_start',
37+
// 'test_start',
38+
// 'hook_start',
39+
// 'hook_success',
40+
// 'test_fn_start',
41+
// 'test_fn_success',
42+
// 'test_done',
43+
// 'run_describe_finish',
44+
// 'run_finish',
45+
// 'teardown',
46+
// ];
47+
// if ( ! ignoredEvents.includes( event.name ) ) {
48+
// // eslint-disable-next-line no-console
49+
// console.log(
50+
// new Date().toString() +
51+
// ' Unhandled event(' +
52+
// event.name +
53+
// '): ' +
54+
// util.inspect( event )
55+
// );
56+
// }
57+
// }
58+
2659
module.exports = E2EEnvironment;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
exitOnPageError: false,
3+
};

tests/e2e/config/jest.setup.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-unused-vars */
12
/**
23
* External dependencies
34
*/
@@ -9,9 +10,14 @@ import {
910
switchUserToTest,
1011
visitAdminPage,
1112
} from '@wordpress/e2e-test-utils';
12-
13+
import { setDefaultOptions } from 'expect-puppeteer';
14+
/**
15+
* Internal dependencies
16+
*/
17+
import { DEFAULT_TIMEOUT } from '../utils';
1318
// Set the default test timeout.
1419
jest.setTimeout( 120000 );
20+
setDefaultOptions( { timeout: DEFAULT_TIMEOUT } );
1521

1622
/**
1723
* Array of page event tuples of [ eventName, handler ].
@@ -105,13 +111,11 @@ function observeConsoleLogging() {
105111
return;
106112
}
107113
const text = message.text();
108-
109114
// Viewing posts on the front end can result in this error, which
110115
// has nothing to do with Gutenberg.
111116
if ( text.includes( 'net::ERR_UNKNOWN_URL_SCHEME' ) ) {
112117
return;
113118
}
114-
115119
// Network errors are ignored only if we are intentionally testing
116120
// offline mode.
117121
if (
@@ -120,9 +124,7 @@ function observeConsoleLogging() {
120124
) {
121125
return;
122126
}
123-
124127
const logFunction = OBSERVED_CONSOLE_MESSAGE_TYPES[ type ];
125-
126128
// Disable reason: We intentionally bubble up console error messages
127129
// for debugging reasons. If you need to test explicitly the logging,
128130
// use @wordpress/jest-console

0 commit comments

Comments
 (0)