Skip to content

Commit

Permalink
#13 Add cypress integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Baiyuan Wang committed Jun 24, 2019
1 parent a22252a commit 232bb4d
Show file tree
Hide file tree
Showing 8 changed files with 611 additions and 35 deletions.
4 changes: 4 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"baseUrl": "http://localhost:3000",
"chromeWebSecurity": false
}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions cypress/integration/user_journey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
context('LuckyDraw', () => {
it('run successfully when normal path', () => {
cy.visit('/');
cy.get('a.creat_new_activity').click()
cy.get('div.activity-setting input').type("XX公司2019年年会")
cy.contains('NEXT').click()
cy.contains('加载示例数据').click()
cy.contains('NEXT').click()
cy.contains('NEXT').click()

cy.contains('start').click()
cy.contains('stop').click()

cy.contains('start').click()
cy.contains('stop').click()

cy.contains('start').click()
cy.contains('stop').click()

cy.contains('next').click()

cy.contains('start').click()
cy.contains('stop').click()

cy.contains('start').click()
cy.contains('stop').click()

cy.contains('next').click()

cy.contains('start').click()
cy.contains('stop').click()

cy.contains('next').click()

cy.contains('抽奖结果').click()
})
});
17 changes: 17 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
},
"devDependencies": {
"concurrently": "^4.1.0",
"cypress": "^3.3.1",
"electron": "^5.0.4",
"electron-builder": "^20.43.0",
"gh-pages": "^2.0.1",
"husky": "^2.4.1",
"react-scripts": "3.0.1",
"redux-devtools-extension": "^2.13.8",
"redux-logger": "^3.0.6",
Expand All @@ -54,7 +56,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"electron-start": "electron .",
"test": "react-scripts test --env=jsdom",
"test:unit": "react-scripts test --env=jsdom",
"test:intergration": "cypress run",
"eject": "react-scripts eject",
"electron-pack": "build -c.extraMetadata.main=build/electron.js",
"electron-dev": "concurrently \"BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\"",
Expand All @@ -64,6 +67,11 @@
"release:web": "gh-pages -d build",
"release": "release-it"
},
"husky": {
"hooks": {
"pre-push": "yarn test:intergration"
}
},
"browserslist": [
">0.2%",
"not dead",
Expand Down
Loading

0 comments on commit 232bb4d

Please sign in to comment.