Rename commands and directories for Playwright and JEST e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/10493)

* Move e2e to e2e-jest

* Move e2e-pw to e2e

* Update e2e usage + scripts

* Missed some directory renames

* Update gitignore

* Remove test results as its in gitignore
This commit is contained in:
Mike Jolley 2023-08-08 17:58:12 +01:00 committed by GitHub
parent be1cefc4b4
commit 2b80d3e830
180 changed files with 65 additions and 52 deletions

View File

@ -8,6 +8,7 @@
/patches
/storybook
/tests
/playwright-report
.editorconfig
.env

View File

@ -7,8 +7,8 @@ node_modules
vendor
legacy
reports
tests/e2e/specs/backend/__fixtures__
tests/e2e/specs/backend/__snapshots__
tests/e2e-jest/specs/backend/__fixtures__
tests/e2e-jest/specs/backend/__snapshots__
storybook/dist
assets/js/interactivity

View File

@ -70,8 +70,8 @@ jobs:
run: |
node ./bin/wp-env-with-gutenberg.js
npm run wp-env start
npm run wp-env:config && npx cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --listTests > ~/.jest-e2e-tests
npx cross-env JEST_PUPPETEER_CONFIG=tests/e2e/config/jest-puppeteer.config.js cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --runInBand --runTestsByPath $( awk 'NR % 5 == ${{ matrix.part }} - 1' < ~/.jest-e2e-tests )
npm run wp-env:config && npx cross-env NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js --listTests > ~/.jest-e2e-tests
npx cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config.js cross-env NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js --runInBand --runTestsByPath $( awk 'NR % 5 == ${{ matrix.part }} - 1' < ~/.jest-e2e-tests )
- name: Upload artifacts on failure
if: ${{ failure() }}
@ -154,8 +154,8 @@ jobs:
WOOCOMMERCE_BLOCKS_PHASE: 3
run: |
npm run wp-env start
npm run wp-env:config && npx cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --listTests > ~/.jest-e2e-tests
npx cross-env JEST_PUPPETEER_CONFIG=tests/e2e/config/jest-puppeteer.config.js cross-env NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --runInBand --runTestsByPath $( awk 'NR % 5 == ${{ matrix.part }} - 1' < ~/.jest-e2e-tests )
npm run wp-env:config && npx cross-env NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js --listTests > ~/.jest-e2e-tests
npx cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config.js cross-env NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js --runInBand --runTestsByPath $( awk 'NR % 5 == ${{ matrix.part }} - 1' < ~/.jest-e2e-tests )
- name: Upload artifacts on failure
if: ${{ failure() }}

View File

@ -57,7 +57,7 @@ jobs:
run: npm run env:start
- name: Run Playwright tests
run: npm run test:e2e-pw
run: npm run test:e2e
- uses: actions/upload-artifact@v3
if: ${{ failure() }}

View File

@ -43,9 +43,10 @@ tests/cli/vendor
# E2E tests
/tests/e2e-tests/config/local-*.json
**/e2e-pw/test-results/
**/e2e-pw/artifacts/
**/e2e/test-results/
**/e2e/artifacts/
/artifacts/
/playwright-report/
# Logs
/logs

View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
if ! docker info > /dev/null 2>&1; then
echo "This script uses docker, and it isn't running - please start docker and try again!"
exit 1
fi
if ! [ "$(docker ps --filter "name=wordpress" --filter "status=running" --quiet)" ]; then
echo "This script uses wp-env, and it isn't running - please start wp-env and try again!"
exit 1
fi

View File

@ -6,13 +6,13 @@
- [Playwright](#playwright)
- [Structure](#structure-1)
This living document serves to prescribe coding guidelines specific to the WooCommerce Blocks project E2E tests. For more information on how to run Playwright end-to-end (E2E) tests, please refer to the [dedicated resource](../../tests/e2e-pw/README.md).
This living document serves to prescribe coding guidelines specific to the WooCommerce Blocks project E2E tests. For more information on how to run Playwright end-to-end (E2E) tests, please refer to the [dedicated resource](../../tests/e2e/README.md).
## Structure
There are two folders dedicated to E2E tests.
The first folder is named "e2e" and it contains all the E2E tests that were created with the deprecated infrastructure Jest + Puppetter. The "e2e-pw" folder contains all the E2E tests that were created with the current infrastructure: Playwright. These tests are actively maintained and should be used for all new E2E testing.
The first folder is named "e2e-jest" and it contains all the E2E tests that were created with the deprecated infrastructure Jest + Puppetter. The "e2e" folder contains all the E2E tests that were created with the current infrastructure: Playwright. These tests are actively maintained and should be used for all new E2E testing.
### Playwright

View File

@ -63,7 +63,7 @@ When you're done, you may want to shut down the test environment:
## How to run end-to-end tests
Visit the [dedicated documentation](../../tests/e2e-pw/README.md).
Visit the [dedicated documentation](../../tests/e2e/README.md).
### Debugging e2e tests using generated reports

View File

@ -79,16 +79,17 @@
"storybook:deploy": "rimraf ./storybook/dist/* && npm run storybook:build && gh-pages -d ./storybook/dist",
"test": "wp-scripts test-unit-js --config tests/js/jest.config.json",
"test:debug": "ndb .",
"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",
"test:e2e-dev": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e/config/jest-puppeteer.config-dev.js NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js",
"test:e2e-dev-watch": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e/config/jest-puppeteer.config-dev.js NODE_CONFIG_DIR=tests/e2e/config wp-scripts test-e2e --config tests/e2e/config/jest.config.js --watch",
"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",
"test:e2e-pw": "npx playwright test --config=tests/e2e-pw/playwright.config.ts",
"env:start": "npm run wp-env start && ./tests/e2e-pw/bin/test-env-setup.sh",
"env:restart": "npm run wp-env clean all && npm run wp-env start && ./tests/e2e-pw/bin/test-env-setup.sh",
"test:e2e": "sh ./bin/check-env.sh && npx playwright test --config=tests/e2e/playwright.config.ts",
"test:e2e:report": "sh ./bin/check-env.sh && npx playwright test --config=tests/e2e/playwright.config.ts --reporter=html",
"test:e2e:jest": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config.js NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js",
"test:e2e:jest:dev": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config-dev.js NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js",
"test:e2e:jest:dev-watch": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config-dev.js NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js --watch",
"test:e2e:jest:update": "npm run wp-env:config && cross-env JEST_PUPPETEER_CONFIG=tests/e2e-jest/config/jest-puppeteer.config.js NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.config.js --updateSnapshot",
"env:start": "npm run wp-env start && ./tests/e2e/bin/test-env-setup.sh",
"env:restart": "npm run wp-env clean all && npm run wp-env start && ./tests/e2e/bin/test-env-setup.sh",
"env:stop": "npm run wp-env stop",
"test:help": "wp-scripts test-unit-js --help",
"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",
"test:performance": "npm run wp-env:config && cross-env NODE_CONFIG_DIR=tests/e2e-jest/config wp-scripts test-e2e --config tests/e2e-jest/config/jest.performance.config.js -- performance",
"test:php": "wp-env run --env-cwd='wp-content/plugins/${PWD##*/}' tests-wordpress vendor/bin/phpunit -c phpunit.xml.dist",
"test:update": "wp-scripts test-unit-js --updateSnapshot --config tests/js/jest.config.json",
"test:watch": "npm run test -- --watch",

View File

@ -16,22 +16,22 @@ module.exports = {
process.env.CI && '@wordpress/e2e-tests/config/flaky-tests-reporter.js',
].filter( Boolean ),
testEnvironment: '<rootDir>/tests/e2e/config/environment.js',
testEnvironment: '<rootDir>/tests/e2e-jest/config/environment.js',
testRunner: 'jest-circus/runner',
// Where to look for test files
roots: [ '<rootDir>/tests/e2e/specs' ],
globalSetup: '<rootDir>/tests/e2e/config/setup.js',
globalTeardown: '<rootDir>/tests/e2e/config/teardown.js',
roots: [ '<rootDir>/tests/e2e-jest/specs' ],
globalSetup: '<rootDir>/tests/e2e-jest/config/setup.js',
globalTeardown: '<rootDir>/tests/e2e-jest/config/teardown.js',
setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework
// before each test
setupFilesAfterEnv: [
'<rootDir>/tests/e2e/config/custom-matchers/index.js',
'<rootDir>/tests/e2e/config/jest.setup.js',
'<rootDir>/tests/e2e-jest/config/custom-matchers/index.js',
'<rootDir>/tests/e2e-jest/config/jest.setup.js',
'expect-puppeteer',
],
testPathIgnorePatterns: [
'<rootDir>/tests/e2e/specs/performance',
'<rootDir>/tests/e2e-jest/specs/performance',
// Ignore all the files that have utils in the name
'utils',
],

View File

@ -3,11 +3,11 @@ module.exports = {
reporters: [
'default',
'<rootDir>/tests/e2e/config/performance-reporter.js',
'<rootDir>/tests/e2e-jest/config/performance-reporter.js',
],
// Where to look for test files
roots: [ '<rootDir>/tests/e2e/specs/performance' ],
roots: [ '<rootDir>/tests/e2e-jest/specs/performance' ],
testPathIgnorePatterns: [],
};

Some files were not shown because too many files have changed in this diff Show More