Skip to content

Upgrade Nightwatch to v1.2 and update bundled config and generated tests #4541

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

Merged
merged 10 commits into from
Sep 9, 2019
59 changes: 51 additions & 8 deletions packages/@vue/cli-plugin-e2e-nightwatch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ Working with page objects is a popular methodology in end-to-end UI testing. Fil
#### `globals.js`
The external globals file which can hold global properties or hooks. See [test globals](https://nightwatchjs.org/gettingstarted/configuration/#test-globals) section.

## Installing in an Already Created Project

``` sh
vue add e2e-nightwatch
```

## Configuration

We've pre-configured Nightwatch to run with Chrome by default. Firefox is also available via `--env firefox`. If you wish to run end-to-end tests in additional browsers (e.g. Safari, Microsoft Edge), you will need to add a `nightwatch.conf.js` or `nightwatch.json` in your project root to configure additional browsers. The config will be merged into the [internal Nightwatch config](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-e2e-nightwatch/nightwatch.config.js).
Expand All @@ -68,6 +74,30 @@ Alternatively, you can completely replace the internal config with a custom conf

Consult Nightwatch docs for [configuration options](https://nightwatchjs.org/gettingstarted/configuration/) and how to [setup browser drivers](http://nightwatchjs.org/gettingstarted#browser-drivers-setup).

## Running Tests

By default, all tests inside the `specs` folder will be run using Chrome. If you'd like to run end-to-end tests against Chrome (or Firefox) in headless mode, simply pass the `--headless` argument.

```sh
$ vue-cli-service test:e2e
```

**Running a single test**

To run a single test supply the filename path. E.g.:

```sh
$ vue-cli-service test:e2e tests/e2e/specs/test.js
```

**Skip Dev server auto-start**

If the development server is already running and you want to skip starting it automatically, pass the `--url` argument:

```sh
$ vue-cli-service test:e2e --url http://localhost:8080/
```

**Running in Firefox**

Support for running tests in Firefox is also available by default. Simply run the following (optionally add `--headless` to run Firefox in headless mode):
Expand All @@ -76,6 +106,14 @@ Support for running tests in Firefox is also available by default. Simply run th
$ vue-cli-service test:e2e --env firefox [--headless]
```

**Running in Firefox and Chrome simultaneously**

You can also run the tests simultaneously in both browsers by supplying both test environments separated by a comma (",") - no spaces.

```sh
$ vue-cli-service test:e2e --env firefox,chrome [--headless]
```

**Running Tests in Parallel**

For a significantly faster test run, you can enable parallel test running when there are several test suites. Concurrency is performed at the file level and is distributed automatically per available CPU core.
Expand All @@ -88,13 +126,18 @@ $ vue-cli-service test:e2e --parallel

**Running with Selenium**

In most cases, running with Selenium is not required since Nightwatch v1.0. It is still possible with the following:
```sh
$ vue-cli-service test:e2e --use-selenium
```
Since `v4`, the Selenium standalone server is not included anymore in this plugin and in most cases running with Selenium is not required since Nightwatch v1.0.

## Installing in an Already Created Project
It is still possible to use the Selenium server, by following these steps:

``` sh
vue add e2e-nightwatch
```
__1.__ Install `selenium-server` NPM package:

```sh
$ npm install selenium-server --save-dev
```

__2.__ Run with `--use-selenium` cli argument:

```sh
$ vue-cli-service test:e2e --use-selenium
```
3 changes: 2 additions & 1 deletion packages/@vue/cli-plugin-e2e-nightwatch/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = api => {
'test:e2e': 'vue-cli-service test:e2e'
},
devDependencies: {
chromedriver: '^74.0.0'
chromedriver: '^76.0.1',
geckodriver: '^1.16.2'
}
})
}
4 changes: 3 additions & 1 deletion packages/@vue/cli-plugin-e2e-nightwatch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
"nightwatch": "^1.2.2"
},
"devDependencies": {
"selenium-server": "^3.141.59",
"chromedriver": "^76.0.1",
"geckodriver": "^1.16.2"
},
"optionalDependencies": {
"selenium-server": "^3.141.59"
},
"peerDependencies": {
"@vue/cli-service": "^3.0.0 || ^4.0.0-0",
"chromedriver": "*",
Expand Down