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

feat: E2E test suite with puppeteer+ipfsd-ctl #1353

Merged
merged 21 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
- run:
command: npm run build
- run:
command: npm run test:e2e:ci
command: E2E_IPFSD_TYPE=go npm run test:e2e
- run:
command: E2E_IPFSD_TYPE=js npm run test:e2e
- run:
command: npm run bundlesize
- persist_to_workspace:
Expand Down
56 changes: 50 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,73 @@ The WebUI uses Jest to run the isolated unit tests. Unit test files are located

## End-to-end tests

The end-to-end tests (e2e) test the full app in a headless Chromium browser. They require an http server to be running to serve the app.
The end-to-end tests (e2e) test the full app in a headless Chromium browser. They spawn real IPFS node for HTTP API and a static HTTP server to serve the app.
The purpose of those tests is not being comprehensible, but act as a quick regression and integration suite.

In dev, run `npm start` in another shell before starting the tests

```
# Run the end-to-end tests
# Run the end-to-end tests (fast, headless)
> npm run test:e2e
```

By default the test run headless, so you won't see the the browser. To debug test errors, it can be helpful to see the robot clicking around the site. To disable headless mode and see the browser, set the environment variable `DEBUG=true`
### Customizing IPFS backend

#### `E2E_IPFSD_TYPE`

Pass environment variable named `E2E_IPFSD_TYPE` to specify which IPFS backend should be used for end-to-end tests.

CI setup runs tests against both:

```console
$ E2E_IPFSD_TYPE=go npm run test:e2e # 'go' is the default if missing
$ E2E_IPFSD_TYPE=js npm run test:e2e
```

It is possible to test against arbitrary versions by tweaking `ipfs` (js-ipfs)
and `go-ipfs-dep` (go-ipfs) in `package.json` and applying change via `npm i`.

#### `E2E_API_URL`

Instead of spawning disposable node and repo for tests, one can point E2E test suite at arbitrary HTTP API:

```console
$ E2E_API_URL=http://127.0.0.1:5001 npm run test:e2e
```

**Caveat:** CORS requests from `http://localhost:3001` (static server hosting dev version of webui) need to be added to `Access-Control-Allow-Origin` whitelist array in node's config:

```json
"API": {
"HTTPHeaders": {
"Access-Control-Allow-Origin": [
"http://localhost:3001"
```

Can be done ad-hoc via command line:

```console
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://localhost:3001"]'
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
```
# See the end-to-end tests in a browser

### Debugging E2E tests

By default the test run headless, so you won't see the the browser. To debug test errors, it can be helpful to see the robot clicking around the site.
To disable headless mode and see the browser, set the environment variable `DEBUG=true` and optionally use `await jestPuppeteer.debug()` to stop tests at a specific line.

```
# See the end-to-end tests in slowed down mode and a browser
> DEBUG=true npm run test:e2e
```

In a **continuous integration** environment we lint the code, run the unit tests, build the app, start an http server and run the unit e2e tests.
In a **continuous integration** environment we lint the code, run the unit tests, build the app, start an http server and run the unit e2e tests:

```sh
> npm run lint
> npm test
> npm run build
> npm run test:ci:e2e
> npm run test:e2e
```

## Coverage
Expand Down