woocommerce/plugins/woocommerce-blocks/tests/e2e
Albert Juhé Lluveras 081f9d303b
Move Cart, Checkout and Order Confirmation template customization tests to the parameterized tests file (#43992)
* Move Cart, Checkout and Order Confirmation template customization tests to the parameterized tests file

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Clean up order-confirmation.block_theme.spec.ts file

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-01-24 15:26:07 +01:00
..
bin Migrate mini cart tests (#43549) 2024-01-16 13:58:54 +07:00
mocks/custom-plugins Update @wordpress/env to 8.1.1 and re-enable PHP Unit Tests for PHP v 8.1 and 8.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9875) 2023-09-01 16:07:55 +07:00
playwright-utils E2E tests migration: performance -> cart (#42943) 2024-01-15 21:03:24 +04:00
test-data/data Add Playwright tests for All Reviews, Reviews by Product and Reviews by Category blocks (#42903) 2023-12-22 09:33:18 +01:00
tests Move Cart, Checkout and Order Confirmation template customization tests to the parameterized tests file (#43992) 2024-01-24 15:26:07 +01:00
types Rename commands and directories for Playwright and JEST e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/10493) 2023-08-08 17:58:12 +01:00
utils Add e2e tests to verify block templates can be customized if the theme has its own custom templates (#43650) 2024-01-18 11:39:24 +01:00
wc-blocks-eslint-rules Playwright: Add eslint rule to prevent import `test` or `expect` from playwright library (https://github.com/woocommerce/woocommerce-blocks/pull/11475) 2023-10-30 11:23:40 -03:00
.eslintrc.js Playwright: Add eslint rule to prevent import `test` or `expect` from playwright library (https://github.com/woocommerce/woocommerce-blocks/pull/11475) 2023-10-30 11:23:40 -03:00
README.md Update WC Blocks Playwright tests docs so we pass parameters correctly to PNPM scripts (#43779) 2024-01-22 11:20:59 +01:00
block-theme-with-templates.setup.ts Add e2e tests to verify block templates can be customized if the theme has its own custom templates (#43650) 2024-01-18 11:39:24 +01:00
block-theme.setup.ts Refactor Cart and Checkout Page Templates (https://github.com/woocommerce/woocommerce-blocks/pull/10773) 2023-09-19 10:58:18 +01:00
classic-theme.setup.ts Update @wordpress/env to 8.1.1 and re-enable PHP Unit Tests for PHP v 8.1 and 8.2 (https://github.com/woocommerce/woocommerce-blocks/pull/9875) 2023-09-01 16:07:55 +07:00
global-setup.ts Playwright E2E tests: Multiple signed in roles (https://github.com/woocommerce/woocommerce-blocks/pull/10561) 2023-12-08 17:44:59 +01:00
global-teardown.ts Rename commands and directories for Playwright and JEST e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/10493) 2023-08-08 17:58:12 +01:00
playwright.block-theme-with-templates.config.ts Add e2e tests to verify block templates can be customized if the theme has its own custom templates (#43650) 2024-01-18 11:39:24 +01:00
playwright.classic-theme.config.ts Playwright test workflow migration from Blocks repo (#42804) 2023-12-15 09:34:29 -08:00
playwright.config.ts Playwright test workflow migration from Blocks repo (#42804) 2023-12-15 09:34:29 -08:00
playwright.side-effects.config.ts Playwright test workflow migration from Blocks repo (#42804) 2023-12-15 09:34:29 -08:00
tsconfig.json Rename commands and directories for Playwright and JEST e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/10493) 2023-08-08 17:58:12 +01:00

README.md

WooCommerce Blocks Playwright End to End Tests

This is the documentation for the new E2E testing setup based on Playwright and wp-env. Over time, these playwright E2E tests should replace the current Puppeteer E2E tests.

Table of contents

Pre-requisites

Note, that if you are on Mac and you install docker through other methods such as homebrew, for example, your steps to set it up might be different. The commands listed in steps below may also vary.

If you are using Windows, we recommend using Windows Subsystem for Linux (WSL) for running E2E tests. Follow the WSL Setup Instructions first before proceeding with the steps below.

Introduction

End-to-end tests are powered by Playwright. The test site is spun up using wp-env (recommended), but we will continue to support e2e-environment in the meantime.

Running tests for the first time

In the root directory, run:

nvm use
pnpm install

Now change directory to plugins/woocommerce-blocks/:

cd plugins/woocommerce-blocks/
pnpm run env:start
pnpm run test:e2e

To run the test again, re-create the environment to start with a fresh state

pnpm run env:restart
pnpm run test:e2e

Tests with side effects

We call tests that affect other tests (ones that modify the site settings, using custom plugins) are tests with side effects and we split those tests to a separate test suite:

pnpm run test:e2e:side-effects

Note: All command parameters of test:e2e can be used for test:e2e:side-effects.

Tests with a classic theme and a block theme with custom templates

By default, e2e tests run in a non-customized block theme. However, we also have some e2e tests which run specifically in a classic theme and in a block theme with custom templates. They can be run like this:

pnpm run test:e2e:classic-theme
pnpm run test:e2e:block-theme-with-templates

_Note: All command parameters of test:e2e can be used for these commands too.

Other ways of running tests

Headless mode:

pnpm run test:e2e

Interactive UI mode:

pnpm run test:e2e --ui

Headed mode:

pnpm run test:e2e --headed

Debug mode:

pnpm run test:e2e --debug

Running a single test:

pnpm run test:e2e ./tests/e2e/tests/example.spec.ts

To see all options, run the following command:

npx playwright test --help