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 /patches
/storybook /storybook
/tests /tests
/playwright-report
.editorconfig .editorconfig
.env .env

View File

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

View File

@ -70,8 +70,8 @@ jobs:
run: | run: |
node ./bin/wp-env-with-gutenberg.js node ./bin/wp-env-with-gutenberg.js
npm run wp-env start 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 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/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 ) 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 - name: Upload artifacts on failure
if: ${{ failure() }} if: ${{ failure() }}
@ -154,8 +154,8 @@ jobs:
WOOCOMMERCE_BLOCKS_PHASE: 3 WOOCOMMERCE_BLOCKS_PHASE: 3
run: | run: |
npm run wp-env start 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 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/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 ) 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 - name: Upload artifacts on failure
if: ${{ failure() }} if: ${{ failure() }}

View File

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

View File

@ -43,9 +43,10 @@ tests/cli/vendor
# E2E tests # E2E tests
/tests/e2e-tests/config/local-*.json /tests/e2e-tests/config/local-*.json
**/e2e-pw/test-results/ **/e2e/test-results/
**/e2e-pw/artifacts/ **/e2e/artifacts/
/artifacts/ /artifacts/
/playwright-report/
# Logs # Logs
/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) - [Playwright](#playwright)
- [Structure](#structure-1) - [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 ## Structure
There are two folders dedicated to E2E tests. 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 ### Playwright
@ -20,9 +20,9 @@ The first folder is named "e2e" and it contains all the E2E tests that were crea
There are three Playwright projects configuration: There are three Playwright projects configuration:
- blockTheme - blockTheme
- blockThemeWithGlobalSideEffects - blockThemeWithGlobalSideEffects
- classicTheme - classicTheme
The blockTheme project runs the tests with the suffix _block_theme_. In this case, the theme is a block theme. The block theme is the default WordPress theme. Currently, it is Twenty-Twenty Three. You should use this configuration if you want test the block with the Site Editor. The blockTheme project runs the tests with the suffix _block_theme_. In this case, the theme is a block theme. The block theme is the default WordPress theme. Currently, it is Twenty-Twenty Three. You should use this configuration if you want test the block with the Site Editor.

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 ## 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 ### 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", "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": "wp-scripts test-unit-js --config tests/js/jest.config.json",
"test:debug": "ndb .", "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": "sh ./bin/check-env.sh && npx playwright test --config=tests/e2e/playwright.config.ts",
"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:report": "sh ./bin/check-env.sh && npx playwright test --config=tests/e2e/playwright.config.ts --reporter=html",
"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: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: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: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-pw": "npx playwright test --config=tests/e2e-pw/playwright.config.ts", "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",
"env:start": "npm run wp-env start && ./tests/e2e-pw/bin/test-env-setup.sh", "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:restart": "npm run wp-env clean all && npm run wp-env start && ./tests/e2e-pw/bin/test-env-setup.sh", "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", "env:stop": "npm run wp-env stop",
"test:help": "wp-scripts test-unit-js --help", "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: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:update": "wp-scripts test-unit-js --updateSnapshot --config tests/js/jest.config.json",
"test:watch": "npm run test -- --watch", "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', process.env.CI && '@wordpress/e2e-tests/config/flaky-tests-reporter.js',
].filter( Boolean ), ].filter( Boolean ),
testEnvironment: '<rootDir>/tests/e2e/config/environment.js', testEnvironment: '<rootDir>/tests/e2e-jest/config/environment.js',
testRunner: 'jest-circus/runner', testRunner: 'jest-circus/runner',
// Where to look for test files // Where to look for test files
roots: [ '<rootDir>/tests/e2e/specs' ], roots: [ '<rootDir>/tests/e2e-jest/specs' ],
globalSetup: '<rootDir>/tests/e2e/config/setup.js', globalSetup: '<rootDir>/tests/e2e-jest/config/setup.js',
globalTeardown: '<rootDir>/tests/e2e/config/teardown.js', globalTeardown: '<rootDir>/tests/e2e-jest/config/teardown.js',
setupFiles: [], setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework // A list of paths to modules that run some code to configure or set up the testing framework
// before each test // before each test
setupFilesAfterEnv: [ setupFilesAfterEnv: [
'<rootDir>/tests/e2e/config/custom-matchers/index.js', '<rootDir>/tests/e2e-jest/config/custom-matchers/index.js',
'<rootDir>/tests/e2e/config/jest.setup.js', '<rootDir>/tests/e2e-jest/config/jest.setup.js',
'expect-puppeteer', 'expect-puppeteer',
], ],
testPathIgnorePatterns: [ testPathIgnorePatterns: [
'<rootDir>/tests/e2e/specs/performance', '<rootDir>/tests/e2e-jest/specs/performance',
// Ignore all the files that have utils in the name // Ignore all the files that have utils in the name
'utils', 'utils',
], ],

View File

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

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