Skip to content

Commit 6f58920

Browse files
feat(cli-service): add WebdriverIO plugin for e2e testing
1 parent a91649e commit 6f58920

File tree

15 files changed

+5246
-1
lines changed

15 files changed

+5246
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__tests__
2+
__mocks__
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# @vue/cli-plugin-e2e-webdriverio
2+
3+
> e2e-webdriverio plugin for vue-cli
4+
5+
## Injected Commands
6+
7+
- **`vue-cli-service test:e2e`**
8+
9+
Run end-to-end tests with [WebdriverIO](https://webdriver.io/).
10+
11+
Options:
12+
13+
```
14+
--remote Run tests remotely on SauceLabs
15+
16+
All WebdriverIO CLI options are also supported.
17+
18+
```
19+
20+
Additionally, all [WebdriverIO CLI options](https://webdriver.io/docs/clioptions.html) are also supported.
21+
E.g.: `--baseUrl`, `--bail` etc.
22+
23+
24+
## Project Structure
25+
26+
The following structure will be generated when installing this plugin:
27+
28+
```
29+
tests/e2e/
30+
├── pageobjects/
31+
| └── app.js
32+
├── specs/
33+
| ├── app.spec.js
34+
└── globals.js
35+
```
36+
37+
In addition to that there will be 3 configuration files generated:
38+
39+
- `wdio.shared.conf.js`: a shared configuration with all options defined for all environments
40+
- `wdio.local.conf.js`: a local configuration for local testing
41+
- `wdio.sauce.conf.js`: a remote configuration for testing on a cloud provider like [Sauce Labs](https://saucelabs.com/)
42+
43+
The directories contain:
44+
45+
#### `pageobjects`
46+
Contains an example for an page object. Read more on using [PageObjects](https://webdriver.io/docs/pageobjects.html) with WebdriverIO.
47+
48+
#### `specs`
49+
Your e2e tests.
50+
51+
## Installing in an Already Created Project
52+
53+
``` sh
54+
vue add e2e-nightwatch
55+
```
56+
57+
## Running Tests
58+
59+
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. Tests will be automatically run in parallel when executed in the cloud.
60+
61+
```sh
62+
$ vue-cli-service test:e2e
63+
```
64+
65+
**Running a single test**
66+
67+
To run a single test supply the filename path. E.g.:
68+
69+
```sh
70+
$ vue-cli-service test:e2e --spec tests/e2e/specs/test.js
71+
```
72+
73+
**Skip Dev server auto-start**
74+
75+
If the development server is already running and you want to skip starting it automatically, pass the `--url` argument:
76+
77+
```sh
78+
$ vue-cli-service test:e2e --baseUrl=http://localhost:8080/
79+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = api => {
2+
api.render('./template', {
3+
hasTS: api.hasPlugin('typescript'),
4+
hasESLint: api.hasPlugin('eslint')
5+
})
6+
7+
api.extendPackage({
8+
scripts: {
9+
'test:e2e': 'vue-cli-service test:e2e'
10+
}
11+
})
12+
}

packages/@vue/cli-plugin-e2e-webdriverio/generator/template/logs/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<%_ if (hasESLint) { _%>
2+
module.exports = {
3+
plugins: ['wdio'],
4+
extends: 'plugin:wdio/recommended',
5+
env: {
6+
mocha: true
7+
},
8+
rules: {
9+
strict: 'off'
10+
}
11+
}
12+
<%_ } _%>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class App {
2+
/**
3+
* elements
4+
*/
5+
get heading () { return $('h1') }
6+
7+
/**
8+
* methods
9+
*/
10+
open (path = '/') {
11+
browser.url(path)
12+
}
13+
}
14+
15+
module.exports = new App()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const App = require('../pageobjects/app')
2+
3+
describe('Vue.js app', () => {
4+
it('should open and render', () => {
5+
App.open()
6+
expect(App.heading).toHaveText('Welcome to Your Vue.js App')
7+
})
8+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { config } = require('./wdio.shared.conf')
2+
3+
exports.config = {
4+
/**
5+
* base config
6+
*/
7+
...config,
8+
/**
9+
* config for local testing
10+
*/
11+
maxInstances: 1,
12+
services: ['chromedriver'],
13+
capabilities: [{
14+
browserName: 'chrome',
15+
'goog:chromeOptions': {
16+
args: process.argv.includes('--headless')
17+
? ['--headless', '--disable-gpu']
18+
: []
19+
}
20+
}]
21+
}
22+
23+
24+
console.log(process.argv);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const { config } = require('./wdio.shared.conf')
2+
3+
const BUILD_ID = Math.ceil(Date.now() / 1000)
4+
5+
exports.config = {
6+
/**
7+
* base config
8+
*/
9+
...config,
10+
/**
11+
* config for testing on Sauce Labs
12+
*/
13+
user: process.env.SAUCE_USERNAME,
14+
key: process.env.SAUCE_ACCESS_KEY,
15+
region: 'us',
16+
headless: process.argv.includes('--headless'),
17+
18+
services: [
19+
['sauce', {
20+
sauceConnect: true,
21+
tunnelIdentifier: 'Vue.js Integration tests'
22+
}]
23+
],
24+
25+
maxInstances: 10,
26+
capabilities: [{
27+
browserName: 'firefox',
28+
browserVersion: 'latest',
29+
platformName: 'Windows 10',
30+
'sauce:options': {
31+
build: `Build ${BUILD_ID}`
32+
}
33+
}, {
34+
browserName: 'chrome',
35+
browserVersion: 'latest',
36+
platformName: 'Windows 10',
37+
'sauce:options': {
38+
build: `Build ${BUILD_ID}`
39+
}
40+
}]
41+
}

0 commit comments

Comments
 (0)