Skip to content

Commit 3a2208a

Browse files
committed
initial
0 parents commit 3a2208a

File tree

16 files changed

+6423
-0
lines changed

16 files changed

+6423
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules
2+
.DS_Store
3+
design
4+
*.log
5+
packages/test
6+
dist
7+
temp
8+
.vuerc
9+
.version
10+
.versions
11+
.changelog

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__tests__
2+
__mocks__

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# @vue/cli-plugin-e2e-cypress
2+
3+
> e2e-cypress plugin for vue-cli
4+
5+
This adds E2E testing support using [Cypress](https://www.cypress.io/).
6+
7+
Cypress offers a rich interactive interface for running E2E tests, but currently only supports running the tests in Chromium. If you have a hard requirement on E2E testing in multiple browsers, consider using the Selenium-based [@vue/cli-plugin-e2e-nightwatch](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-e2e-nightwatch).
8+
9+
## Injected Commands
10+
11+
- **`vue-cli-service test:e2e`**
12+
13+
Run e2e tests with `cypress run`.
14+
15+
By default it launches Cypress in interactive mode with a GUI. If you want to run the tests in headless mode (e.g. for CI), you can do so with the `--headless` option.
16+
17+
The command automatically starts a server in production mode to run the e2e tests against. If you want to run the tests multiple times without having to restart the server every time, you can start the server with `vue-cli-service serve --mode production` in one terminal, and then run e2e tests against that server using the `--url` option.
18+
19+
Options:
20+
21+
```
22+
--headless run in headless mode without GUI
23+
--mode specify the mode the dev server should run in. (default: production)
24+
--url run e2e tests against given url instead of auto-starting dev server
25+
-s, --spec (headless only) runs a specific spec file. defaults to "all"
26+
```
27+
28+
Additionally:
29+
30+
- In GUI mode, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open);
31+
- In `--headless` mode, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
32+
33+
Examples :
34+
- Run Cypress in headless mode for a specific file: `vue-cli-service test:e2e --headless --spec tests/e2e/specs/actions.spec.js`
35+
36+
## Configuration
37+
38+
We've pre-configured Cypress to place most of the e2e testing related files under `<projectRoot>/tests/e2e`. You can also check out [how to configure Cypress via `cypress.json`](https://docs.cypress.io/guides/references/configuration.html#Options).
39+
40+
## Environment Variables
41+
42+
Cypress doesn't load .env files for your test files the same way as `vue-cli` does for your [application code](https://cli.vuejs.org/guide/mode-and-env.html#using-env-variables-in-client-side-code). Cypress supports a few ways to [define env variables](https://docs.cypress.io/guides/guides/environment-variables.html#) but the easiest one is to use .json files (either `cypress.json` or `cypress.env.json`) to define environment variables. Keep in mind those variables are accessible via `Cypress.env` function instead of regular `process.env` object.
43+
44+
## Installing in an Already Created Project
45+
46+
``` sh
47+
vue add e2e-cypress
48+
```

__tests__/codeceptjsPlugin.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
jest.setTimeout(process.env.APPVEYOR ? 120000 : 60000)
2+
3+
const create = require('@vue/cli-test-utils/createTestProject')
4+
5+
test('should work', async () => {
6+
const project = await create('e2e-codeceptjs', {
7+
plugins: {
8+
'vue-cli-plugin-e2e-codeceptjs': {},
9+
}
10+
})
11+
12+
if (!process.env.CI) {
13+
await project.run(`vue-cli-service test:e2e`)
14+
} else if (!process.env.APPVEYOR) {
15+
await project.run(`vue-cli-service test:e2e --headless`)
16+
}
17+
})

generator/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = api => {
2+
api.render('./template');
3+
4+
// These dependencies always need to be added
5+
const devDependencies = {
6+
"codeceptjs": "^2.3.6",
7+
"@codeceptjs/configure": "^0.4.0",
8+
"@codeceptjs/ui": "^0.2.0",
9+
"puppeteer": "^2.0.0"
10+
};
11+
12+
api.extendPackage({
13+
devDependencies,
14+
scripts: {
15+
'test:e2e': 'vue-cli-service test:e2e',
16+
'test:e2e:parallel': 'vue-cli-service test:e2e:parallel',
17+
'test:e2e:open': 'vue-cli-service test:e2e:open',
18+
},
19+
});
20+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { setHeadlessWhen, setWindowSize } = require('@codeceptjs/configure');
2+
3+
setHeadlessWhen(process.env.HEADLESS);
4+
setWindowSize(1400, 1000);
5+
6+
exports.config = {
7+
tests: './tests/e2e/**/*_test.js',
8+
output: './tests/e2e/output',
9+
helpers: {
10+
Puppeteer: {
11+
url: 'http://127.0.0.1:8080',
12+
show: true,
13+
}
14+
},
15+
include: {
16+
I: './tests/e2e/support/steps_file.js'
17+
},
18+
plugins: {
19+
retryFailedStep: {
20+
enabled: true,
21+
},
22+
screenshotOnFail: {
23+
enabled: true
24+
},
25+
},
26+
name: 'vue e2e tests'
27+
};

generator/template/jsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOption": {
3+
"allowJs": true
4+
},
5+
"files": [
6+
"tests/e2e/steps.d.ts"
7+
]
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Feature('App');
2+
3+
Scenario('Open app', (I) => {
4+
I.amOnPage('/');
5+
I.see('Vue');
6+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Folder holder');
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// in this file you can append custom step methods to 'I' object
2+
3+
module.exports = function() {
4+
return actor({
5+
6+
// Define custom steps here, use 'this' to access default methods of I.
7+
// It is recommended to place a general 'login' function here.
8+
9+
});
10+
}

0 commit comments

Comments
 (0)