Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Update testing overview documentation #32829

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions docs/contributors/code/testing-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ Contributors to Gutenberg will note that PRs include continuous integration E2E

End-to-end tests use [Puppeteer](https://github.com/puppeteer/puppeteer) as a headless Chromium driver, and are otherwise still run by a [Jest](https://jestjs.io/) test runner.

### Using wp-env

If you're using the built-in [local environment](/docs/contributors/code/getting-started-with-code-contribution.md#local-environment), you can run the e2e tests locally using this command:

```bash
Expand Down Expand Up @@ -416,12 +418,22 @@ You can additionally have the devtools automatically open for interactive debugg
npm run test-e2e:watch -- --puppeteer-devtools
```

If you're using a different setup, you can provide the base URL, username and password like this:
### Using alternate enviornment

If you're using a different setup than wp-env, you can provide the base URL, username and password like this:

```bash
npm run test-e2e -- --wordpress-base-url=http://localhost:8888 --wordpress-username=admin --wordpress-password=password
```

You also need to symlink all e2e test plugins to your site plugins directory:

```bash
ln -s gutenberg/packages/e2e-tests/plugins/* .
```

### Scenario Testing

If you find that end-to-end tests pass when run locally, but fail in Travis, you may be able to isolate a CPU- or netowrk-bound race condition by simulating a slow CPU or network:

```
Expand All @@ -430,23 +442,23 @@ THROTTLE_CPU=4 npm run test-e2e

`THROTTLE_CPU` is a slowdown factor (in this example, a 4x slowdown multiplier)

Related: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setCPUThrottlingRate
See [Chrome docs: setCPUThrottlingRate](https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setCPUThrottlingRate)

```
SLOW_NETWORK=true npm run test-e2e
```

`SLOW_NETWORK` emulates a network speed equivalent to "Fast 3G" in the Chrome devtools.

Related: https://chromedevtools.github.io/devtools-protocol/tot/Network#method-emulateNetworkConditions and https://github.com/ChromeDevTools/devtools-frontend/blob/80c102878fd97a7a696572054007d40560dcdd21/front_end/sdk/NetworkManager.js#L252-L274
See [Chrome docs: emulateNetworkConditions](https://chromedevtools.github.io/devtools-protocol/tot/Network#method-emulateNetworkConditions) and [NetworkManager.js](https://github.com/ChromeDevTools/devtools-frontend/blob/80c102878fd97a7a696572054007d40560dcdd21/front_end/sdk/NetworkManager.js#L252-L274)

```
OFFLINE=true npm run test-e2e
```

`OFFLINE` emulates network disconnection.

Related: https://chromedevtools.github.io/devtools-protocol/tot/Network#method-emulateNetworkConditions
See [Chrome docs: emulateNetworkConditions](https://chromedevtools.github.io/devtools-protocol/tot/Network#method-emulateNetworkConditions)

### Core Block Testing

Expand Down