woocommerce/plugins/woocommerce-blocks/tests/e2e
Alexandre Lara c8ef0fb3af Product Gallery block: Restrict block to be available only on the Single Product template or the Product Gallery template part (https://github.com/woocommerce/woocommerce-blocks/pull/11664)
* WIP: experimenting with strategy pattern for block registration

* Add TemplateChangeDetector to BlocksRegistrationManager

* Handle blocks registration

* Fix issue causing blocks to be registered multiple times

* Allow register/unregister blocks when on pages or posts

* Add BlockRegistrationStrategy logic

* Fix import error

* Add doc comments for BlockRegistrationManager class

* Add doc comments to TemplateChangeDetector class

* Fix eslint errors

* Import domReady from @wordpress/dom-ready

* Prevent error when using blockName for registerBlockType function

* Add e2e tests to check for block availability in different contexts

* Add e2e tests to cover block availability on different contexts
2023-11-16 15:03:58 +00:00
..
bin e2e: Add hacky workaround for product image gallery (https://github.com/woocommerce/woocommerce-blocks/pull/11655) 2023-11-08 13:55:35 -08: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 Disable test eslint rule for test.ts file (https://github.com/woocommerce/woocommerce-blocks/pull/11497) 2023-10-31 11:16:40 +01:00
test-data/data 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
tests Product Gallery block: Restrict block to be available only on the Single Product template or the Product Gallery template part (https://github.com/woocommerce/woocommerce-blocks/pull/11664) 2023-11-16 15:03:58 +00: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 Playwright Fixes from the 11.5.x release branch (https://github.com/woocommerce/woocommerce-blocks/pull/11737) 2023-11-14 10:32:19 +00: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 Better handling tests with global side effects (https://github.com/woocommerce/woocommerce-blocks/pull/10508) 2023-08-16 12:23:43 +07: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 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-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.classic-theme.config.ts Fix the artifacts path for classic theme (https://github.com/woocommerce/woocommerce-blocks/pull/10837) 2023-09-05 15:03:56 +02:00
playwright.config.ts Product Gallery Block: Next/Previous block (https://github.com/woocommerce/woocommerce-blocks/pull/10235) 2023-08-28 18:32:45 +02:00
playwright.side-effects.config.ts Move cart widget tests to playwright and ensure classic/block theme configs are executed correctly (https://github.com/woocommerce/woocommerce-blocks/pull/10669) 2023-08-28 03:04:28 -07: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

nvm use
npm install
npm run env:start
npm run test:e2e

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

npm run env:restart
npm 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:

npm run test:e2e:side-effects

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

Other ways of running tests

Headless mode:

npm run test:e2e

Interactive UI mode:

npm run test:e2e -- --ui

Headed mode:

npm run test:e2e -- --headed

Debug mode:

npm run test:e2e -- --debug

Running a single test:

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

To see all options, run the following command:

npx playwright test --help