Skip to content

Commit d2481de

Browse files
author
levy
committed
Merge branch 'dev'
2 parents ff5d152 + 80853a5 commit d2481de

File tree

9 files changed

+49
-14
lines changed

9 files changed

+49
-14
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Create an enterprise nuxt app in seconds.
4040
- [x] [PWA](https://pwa.nuxtjs.org) Nuxt Progressive Web Apps solution
4141
- [x] [API Manage](https://github.com/FEMessage/create-nuxt-app/blob/dev/docs/api.md) RESTful API management
4242
- [x] [breadcrumb](https://www.yuque.com/docs/share/2fb86219-e8be-4007-a2b8-39641d5e79df)
43+
- [x] [Cypress](https://www.cypress.io/)
4344

4445
[⬆ Back to Top](#table-of-contents)
4546

template/framework-base/_.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,8 @@ dist
8585
sw.*
8686

8787
package-lock.json
88+
89+
# cypress
90+
test/e2e/screenshots/
91+
test/e2e/videos/
92+

template/modules/cypress/_package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66

77
"devDependencies": {
8-
"cypress": "5.6.0",
8+
"cypress": "^6.0.1",
99
"eslint-plugin-cypress": "^2.11.2"
1010
}
1111
}

template/modules/cypress/cypress.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
"pluginsFile": "test/e2e/plugins/index.js",
55
"screenshotsFolder": "test/e2e/screenshots",
66
"supportFile": "test/e2e/support/index.js",
7-
"videosFolder": "test/e2e/videos"
7+
"videosFolder": "test/e2e/videos",
8+
"viewportWidth": 1280,
9+
"viewportHeight": 800
810
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
/**
2-
* @FYI https://deepexi.yuque.com/docs/share/6537d0c9-6d70-4302-a37d-ba388fd74a15?# 《Cypress 实战
2+
* @FYI https://deepexi.yuque.com/docs/share/6537d0c9-6d70-4302-a37d-ba388fd74a15?# 《Cypress 实战总结
33
*/
44
describe('login', function () {
55
before(() => {
66
cy.fixture('user').as('user')
77

88
cy.visit('/')
9-
cy.viewport(600, 800)
109
})
1110

1211
it('login', function () {
1312
const {code, username, password} = this.user
1413

15-
cy.hash().should('eq', '#/login?redirect=%2F')
16-
1714
cy.get('input[placeholder=租户Id]').type(code)
1815
cy.get('input[placeholder="用户名 / 邮箱"]').fill(username)
19-
cy.get('input[placeholder=密码]').fill(`${password}{enter}`)
20-
// cy.contains('登录').click() // enter 代替 click
16+
cy.get('input[placeholder=密码]').fill(`${password}`)
17+
18+
cy.contains('登录')
19+
.then($el => {
20+
$el.on('click', e => e.preventDefault())
21+
})
22+
.click()
23+
2124
cy.hash().should('eq', '#/')
2225
})
2326
})
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
/**
2+
* https://docs.cypress.io/api/plugins/configuration-api.html#Switch-between-multiple-configuration-files
3+
*/
14
const path = require('path')
2-
const fs = require('fs-extra')
5+
const fs = require('fs')
36

4-
function getConfigurationByFile(file) {
7+
async function getConfigurationByFile(file) {
58
const pathToConfigFile = path.resolve(__dirname, '../config', `${file}.json`)
69

7-
return fs.readJson(pathToConfigFile)
10+
return JSON.parse(await fs.promises.readFile(pathToConfigFile, 'utf-8'))
811
}
912

1013
/**
@@ -15,4 +18,4 @@ module.exports = (_on, config) => {
1518
const file = config.env.config || 'local'
1619

1720
return getConfigurationByFile(file)
18-
}
21+
}

template/modules/gitlab-ci/.gitlab-ci.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
image: node:10
1+
image: node:14
2+
stages:
3+
- deploy
4+
- e2e
5+
26
pages:
7+
stage: deploy
38
cache:
49
paths:
510
- node_modules/
@@ -12,3 +17,19 @@ pages:
1217
- public
1318
only:
1419
- master
20+
21+
cypress:
22+
image:
23+
name: cypress/included:6.0.1
24+
entrypoint: [""]
25+
stage: e2e
26+
when: manual
27+
tags:
28+
- docker
29+
script:
30+
- cypress run --env config=dev
31+
artifacts:
32+
paths:
33+
- test/e2e/screenshots
34+
- test/e2e/video
35+
expire_in: 3 day

test/snapshots/cypress.test.js.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Generated by [AVA](https://ava.li).
332332
'babel-plugin-import': '1.13.0',
333333
'core-js': '3.7.0',
334334
'cross-env': '5.2.1',
335-
cypress: '5.6.0',
335+
cypress: '^6.0.1',
336336
eslint: '7.13.0',
337337
'eslint-config-prettier': '6.15.0',
338338
'eslint-friendly-formatter': '4.0.1',

test/snapshots/cypress.test.js.snap

2 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)