-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
feat(e2e-webdriverio): add e2e plugin for WebdriverIO #5479
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cb42237
feat(cli-service): add WebdriverIO plugin for e2e testing
christian-bromann f8d6e3b
test(e2e-webdriverio): add integration tests
christian-bromann e1122e9
fix(e2e-webdriverio): PR feedback
christian-bromann 3c799cc
fix(e2e-webdriverio): remove package-lock
christian-bromann d35c15e
fix(e2e-webdriverio): PR feedback
christian-bromann e1f9a61
docs(e2e-webdriverio): add WebdriverIO docs
christian-bromann 714a168
fix(e2e-webdriverio): update driver version
christian-bromann 41f0ab1
fix(e2e-webdriverio): update driver version
christian-bromann cfa33e7
fix(e2e-webdriverio): update expected prompts
christian-bromann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# @vue/cli-plugin-e2e-nightwatch | ||
|
||
> e2e-webdriverio plugin for vue-cli | ||
|
||
## Injected Commands | ||
|
||
- **`vue-cli-service test:e2e`** | ||
|
||
Run end-to-end tests with [WebdriverIO](https://webdriver.io/). | ||
|
||
Options: | ||
|
||
``` | ||
--url run the tests against given url instead of auto-starting dev server | ||
--headless use chrome or firefox in headless mode | ||
--remote run e2e tests on a cloud provider | ||
``` | ||
|
||
Additionally, all [WebdriverIO CLI options](https://webdriver.io/docs/clioptions.html) are also supported. | ||
E.g.: `--spec`, `--watch` etc. | ||
|
||
|
||
## Project Structure | ||
|
||
The following structure will be generated when installing this plugin. It includes a spec file a page object definition for the Vue.js app as example. | ||
|
||
``` | ||
tests/e2e/ | ||
├── pageobjects/ | ||
| └── app.page.js | ||
├── specs/ | ||
| ├── app.spec.js | ||
└── .eslintrc.js | ||
``` | ||
|
||
#### `pageobjects` | ||
Working with page objects is a popular methodology in end-to-end UI testing. See [working with page objects](https://webdriver.io/docs/pageobjects.html) section for details. | ||
|
||
#### `specs` | ||
The main location where tests are located. You can specify specific tests or define suites to run various subsets of these tests. [More info](https://webdriver.io/docs/organizingsuites.html). | ||
|
||
## Installing in an Already Created Project | ||
|
||
``` sh | ||
vue add e2e-webdriverio | ||
``` | ||
|
||
## 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 | ||
``` | ||
|
||
This will run the tests automatically in parallel on Firefox and Chrome. | ||
|
||
**Running a single test** | ||
|
||
To run a single test supply the filename path. E.g.: | ||
|
||
```sh | ||
$ vue-cli-service test:e2e --spec tests/e2e/specs/test.js | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__tests__ | ||
__mocks__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# @vue/cli-plugin-e2e-webdriverio | ||
|
||
> e2e-webdriverio plugin for vue-cli | ||
|
||
## Injected Commands | ||
|
||
- **`vue-cli-service test:e2e`** | ||
|
||
Run end-to-end tests with [WebdriverIO](https://webdriver.io/). | ||
|
||
Options: | ||
|
||
``` | ||
--remote Run tests remotely on SauceLabs | ||
|
||
All WebdriverIO CLI options are also supported. | ||
|
||
``` | ||
|
||
Additionally, all [WebdriverIO CLI options](https://webdriver.io/docs/clioptions.html) are also supported. | ||
E.g.: `--baseUrl`, `--bail` etc. | ||
|
||
|
||
## Project Structure | ||
|
||
The following structure will be generated when installing this plugin: | ||
|
||
``` | ||
tests/e2e/ | ||
├── pageobjects/ | ||
| └── app.js | ||
├── specs/ | ||
| ├── app.spec.js | ||
└── globals.js | ||
``` | ||
|
||
In addition to that there will be 3 configuration files generated: | ||
|
||
- `wdio.shared.conf.js`: a shared configuration with all options defined for all environments | ||
- `wdio.local.conf.js`: a local configuration for local testing | ||
- `wdio.sauce.conf.js`: a remote configuration for testing on a cloud provider like [Sauce Labs](https://saucelabs.com/) | ||
|
||
The directories contain: | ||
|
||
#### `pageobjects` | ||
Contains an example for an page object. Read more on using [PageObjects](https://webdriver.io/docs/pageobjects.html) with WebdriverIO. | ||
|
||
#### `specs` | ||
Your e2e tests. | ||
|
||
## Installing in an Already Created Project | ||
|
||
``` sh | ||
vue add e2e-webdriverio | ||
``` | ||
|
||
For users with older CLI versions you may need to run `vue add @vue/e2e-webdriverio`. | ||
|
||
## 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. Tests will be automatically run in parallel when executed in the cloud. | ||
|
||
```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 --spec 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 --baseUrl=http://localhost:8080/ | ||
``` |
41 changes: 41 additions & 0 deletions
41
packages/@vue/cli-plugin-e2e-webdriverio/__tests__/wdioPlugin.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
jest.setTimeout(process.env.APPVEYOR ? 120000 : 60000) | ||
|
||
const create = require('@vue/cli-test-utils/createTestProject') | ||
|
||
test('should work', async () => { | ||
const project = await create('e2e-webdriverio', { | ||
plugins: { | ||
'@vue/cli-plugin-babel': {}, | ||
'@vue/cli-plugin-e2e-webdriverio': {}, | ||
'@vue/cli-plugin-eslint': { | ||
config: 'airbnb', | ||
lintOn: 'save' | ||
} | ||
} | ||
}) | ||
|
||
if (!process.env.CI) { | ||
await project.run(`vue-cli-service test:e2e`) | ||
} else if (!process.env.APPVEYOR) { | ||
await project.run(`vue-cli-service test:e2e --headless`) | ||
} | ||
}) | ||
|
||
test('should work with TS', async () => { | ||
const project = await create('e2e-webdriverio-ts', { | ||
plugins: { | ||
'@vue/cli-plugin-typescript': { | ||
'classComponent': true, | ||
'tsLint': true, | ||
'lintOn': ['save'] | ||
}, | ||
'@vue/cli-plugin-e2e-webdriverio': {} | ||
} | ||
}) | ||
|
||
if (!process.env.CI) { | ||
await project.run(`vue-cli-service test:e2e`) | ||
} else if (!process.env.APPVEYOR) { | ||
await project.run(`vue-cli-service test:e2e --headless`) | ||
} | ||
}) |
35 changes: 35 additions & 0 deletions
35
packages/@vue/cli-plugin-e2e-webdriverio/generator/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { installedBrowsers } = require('@vue/cli-shared-utils') | ||
|
||
module.exports = (api, { webdrivers }) => { | ||
api.render('./template', { | ||
hasTS: api.hasPlugin('typescript'), | ||
hasESLint: api.hasPlugin('eslint') | ||
}) | ||
|
||
const devDependencies = {} | ||
|
||
// Use devDependencies to store latest version number so as to automate update | ||
const pluginDeps = require('../package.json').devDependencies | ||
|
||
if (webdrivers && webdrivers.includes('firefox')) { | ||
devDependencies.geckodriver = pluginDeps.geckodriver | ||
devDependencies['wdio-geckodriver-service'] = pluginDeps['wdio-geckodriver-service'] | ||
} | ||
if (webdrivers && webdrivers.includes('chrome')) { | ||
// chromedriver major version bumps every 6 weeks following Chrome | ||
// so there may be a mismatch between | ||
// user's installed browser version and the default provided version | ||
// fallback to the devDependencies version in case detection fails | ||
devDependencies['wdio-chromedriver-service'] = pluginDeps['wdio-chromedriver-service'] | ||
devDependencies.chromedriver = installedBrowsers.chrome | ||
? installedBrowsers.chrome.match(/^(\d+)\./)[1] | ||
: pluginDeps.chromedriver | ||
} | ||
|
||
api.extendPackage({ | ||
scripts: { | ||
'test:e2e': 'vue-cli-service test:e2e' | ||
}, | ||
devDependencies | ||
}) | ||
} |
Empty file.
12 changes: 12 additions & 0 deletions
12
packages/@vue/cli-plugin-e2e-webdriverio/generator/template/tests/e2e/_eslintrc.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<%_ if (hasESLint) { _%> | ||
module.exports = { | ||
plugins: ['wdio'], | ||
extends: 'plugin:wdio/recommended', | ||
env: { | ||
mocha: true | ||
}, | ||
rules: { | ||
strict: 'off' | ||
} | ||
} | ||
<%_ } _%> |
16 changes: 16 additions & 0 deletions
16
...ages/@vue/cli-plugin-e2e-webdriverio/generator/template/tests/e2e/pageobjects/app.page.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class App { | ||
/** | ||
* elements | ||
*/ | ||
get heading () { return $('h1') } | ||
|
||
/** | ||
* methods | ||
*/ | ||
open (path = '/') { | ||
browser.url(path) | ||
} | ||
} | ||
|
||
<%- hasTS ? 'export default new App()' : 'module.exports = new App()' %> | ||
|
8 changes: 8 additions & 0 deletions
8
packages/@vue/cli-plugin-e2e-webdriverio/generator/template/tests/e2e/specs/app.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<%- hasTS ? 'import App from \'../pageobjects/app.page\'' : 'const App = require(\'../pageobjects/app.page\')' %> | ||
|
||
describe('Vue.js app', () => { | ||
it('should open and render', () => { | ||
App.open() | ||
expect(App.heading).toHaveText('Welcome to Your Vue.js <%- hasTS ? '+ TypeScript ' : '' %>App') | ||
}) | ||
}) |
25 changes: 25 additions & 0 deletions
25
packages/@vue/cli-plugin-e2e-webdriverio/generator/template/wdio.local.conf.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<%- hasTS ? 'const { config } = require(\'./wdio.shared.conf.ts\')' : 'const { config } = require(\'./wdio.shared.conf\')' %> | ||
|
||
exports.config = { | ||
/** | ||
* base config | ||
*/ | ||
...config, | ||
/** | ||
* config for local testing | ||
*/ | ||
maxInstances: 1, | ||
services: ['chromedriver', 'geckodriver'], | ||
capabilities: [{ | ||
browserName: 'chrome', | ||
acceptInsecureCerts: true, | ||
'goog:chromeOptions': { | ||
args: process.argv.includes('--headless') | ||
? ['--headless', '--disable-gpu'] | ||
: [] | ||
} | ||
}, { | ||
browserName: 'firefox', | ||
acceptInsecureCerts: true | ||
}] | ||
} | ||
christian-bromann marked this conversation as resolved.
Show resolved
Hide resolved
|
41 changes: 41 additions & 0 deletions
41
packages/@vue/cli-plugin-e2e-webdriverio/generator/template/wdio.sauce.conf.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<%- hasTS ? 'import { config } from \'./wdio.shared.conf.ts\'' : 'const { config } = require(\'./wdio.shared.conf\')' %> | ||
|
||
const BUILD_ID = Math.ceil(Date.now() / 1000) | ||
|
||
exports.config = { | ||
/** | ||
* base config | ||
*/ | ||
...config, | ||
/** | ||
* config for testing on Sauce Labs | ||
*/ | ||
user: process.env.SAUCE_USERNAME, | ||
key: process.env.SAUCE_ACCESS_KEY, | ||
region: 'us', | ||
headless: process.argv.includes('--headless'), | ||
|
||
services: [ | ||
['sauce', { | ||
sauceConnect: true, | ||
tunnelIdentifier: 'Vue.js Integration tests' | ||
}] | ||
], | ||
|
||
maxInstances: 10, | ||
capabilities: [{ | ||
browserName: 'firefox', | ||
browserVersion: 'latest', | ||
platformName: 'Windows 10', | ||
'sauce:options': { | ||
build: `Build ${BUILD_ID}` | ||
} | ||
}, { | ||
browserName: 'chrome', | ||
browserVersion: 'latest', | ||
platformName: 'Windows 10', | ||
'sauce:options': { | ||
build: `Build ${BUILD_ID}` | ||
} | ||
}] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.