Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Dec 8, 2020
2 parents ff5d152 + 80853a5 commit d2481de
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Create an enterprise nuxt app in seconds.
- [x] [PWA](https://pwa.nuxtjs.org) Nuxt Progressive Web Apps solution
- [x] [API Manage](https://github.com/FEMessage/create-nuxt-app/blob/dev/docs/api.md) RESTful API management
- [x] [breadcrumb](https://www.yuque.com/docs/share/2fb86219-e8be-4007-a2b8-39641d5e79df)
- [x] [Cypress](https://www.cypress.io/)

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

Expand Down
5 changes: 5 additions & 0 deletions template/framework-base/_.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ dist
sw.*

package-lock.json

# cypress
test/e2e/screenshots/
test/e2e/videos/

2 changes: 1 addition & 1 deletion template/modules/cypress/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},

"devDependencies": {
"cypress": "5.6.0",
"cypress": "^6.0.1",
"eslint-plugin-cypress": "^2.11.2"
}
}
4 changes: 3 additions & 1 deletion template/modules/cypress/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"pluginsFile": "test/e2e/plugins/index.js",
"screenshotsFolder": "test/e2e/screenshots",
"supportFile": "test/e2e/support/index.js",
"videosFolder": "test/e2e/videos"
"videosFolder": "test/e2e/videos",
"viewportWidth": 1280,
"viewportHeight": 800
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
/**
* @FYI https://deepexi.yuque.com/docs/share/6537d0c9-6d70-4302-a37d-ba388fd74a15?# 《Cypress 实战
* @FYI https://deepexi.yuque.com/docs/share/6537d0c9-6d70-4302-a37d-ba388fd74a15?# 《Cypress 实战总结
*/
describe('login', function () {
before(() => {
cy.fixture('user').as('user')

cy.visit('/')
cy.viewport(600, 800)
})

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

cy.hash().should('eq', '#/login?redirect=%2F')

cy.get('input[placeholder=租户Id]').type(code)
cy.get('input[placeholder="用户名 / 邮箱"]').fill(username)
cy.get('input[placeholder=密码]').fill(`${password}{enter}`)
// cy.contains('登录').click() // enter 代替 click
cy.get('input[placeholder=密码]').fill(`${password}`)

cy.contains('登录')
.then($el => {
$el.on('click', e => e.preventDefault())
})
.click()

cy.hash().should('eq', '#/')
})
})
11 changes: 7 additions & 4 deletions template/modules/cypress/test/e2e/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/**
* https://docs.cypress.io/api/plugins/configuration-api.html#Switch-between-multiple-configuration-files
*/
const path = require('path')
const fs = require('fs-extra')
const fs = require('fs')

function getConfigurationByFile(file) {
async function getConfigurationByFile(file) {
const pathToConfigFile = path.resolve(__dirname, '../config', `${file}.json`)

return fs.readJson(pathToConfigFile)
return JSON.parse(await fs.promises.readFile(pathToConfigFile, 'utf-8'))
}

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

return getConfigurationByFile(file)
}
}
23 changes: 22 additions & 1 deletion template/modules/gitlab-ci/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
image: node:10
image: node:14
stages:
- deploy
- e2e

pages:
stage: deploy
cache:
paths:
- node_modules/
Expand All @@ -12,3 +17,19 @@ pages:
- public
only:
- master

cypress:
image:
name: cypress/included:6.0.1
entrypoint: [""]
stage: e2e
when: manual
tags:
- docker
script:
- cypress run --env config=dev
artifacts:
paths:
- test/e2e/screenshots
- test/e2e/video
expire_in: 3 day
2 changes: 1 addition & 1 deletion test/snapshots/cypress.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ Generated by [AVA](https://ava.li).
'babel-plugin-import': '1.13.0',
'core-js': '3.7.0',
'cross-env': '5.2.1',
cypress: '5.6.0',
cypress: '^6.0.1',
eslint: '7.13.0',
'eslint-config-prettier': '6.15.0',
'eslint-friendly-formatter': '4.0.1',
Expand Down
Binary file modified test/snapshots/cypress.test.js.snap
Binary file not shown.

0 comments on commit d2481de

Please sign in to comment.