@wordpress/e2e-tests Edit

End-To-End (E2E) tests for WordPress.

Installation Installation

Install the module

npm install @wordpress/e2e-tests --save-dev

Top ↑

Running tests Running tests

The following commands are available on the Gutenberg repo:

{
    "test-e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js",
    "test-e2e:debug": "wp-scripts --inspect-brk test-e2e --config packages/e2e-tests/jest.config.js --puppeteer-devtools",
    "test-e2e:watch": "npm run test-e2e -- --watch",
}

Top ↑

Run all available tests Run all available tests

npm run test-e2e

Top ↑

Run all available tests and listen for changes. Run all available tests and listen for changes.

npm run test-e2e:watch

Top ↑

Run a specific test file Run a specific test file

npm run test-e2e -- packages/e2e-test/<path_to_test_file>
# Or, in order to watch for changes:
npm run test-e2e:watch -- packages/e2e-test/<path_to_test_file>

Top ↑

Debugging Debugging

Makes e2e tests available to debug in a Chrome Browser.

npm run test-e2e:debug

After running the command, tests will be available for debugging in Chrome by going to chrome://inspect/#devices and clicking inspect under the path to /test-e2e.js.

Top ↑

Debugging in vscode Debugging in vscode

Debugging in a Chrome browser can be replaced with vscode‘s debugger by adding the following configuration to .vscode/launch.json:

{
            "type": "node",
            "request": "launch",
            "name": "Debug current e2e test",
            "program": "${workspaceFolder}/node_modules/@wordpress/scripts/bin/wp-scripts.js",
            "args": [
                "test-e2e",
                "--config=${workspaceFolder}/packages/e2e-tests/jest.config.js",
                "--verbose=true",
                "--runInBand",
                "--watch",
                "${file}"
            ],
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen",
            "trace": "all"
        }

This will run jest, targetting the spec file currently open in the editor. vscode‘s debugger can now be used to add breakpoints and inspect tests as you would in Chrome DevTools.

Note: This package requires Node.js 12.0.0 or later. It is not compatible with older versions.

Code is Poetry.