Skip to content

Commit 4fa72b1

Browse files
committed
feat: enable cypress e2e tests
1 parent 59f1026 commit 4fa72b1

13 files changed

Lines changed: 206 additions & 40 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference types="Cypress" />
2+
3+
context('The app', () => {
4+
it('shows home page', () => {
5+
cy.visit('/');
6+
cy.title().should('equal', 'Home | Dumber Demo');
7+
cy.get('router-view').contains('Home!');
8+
});
9+
10+
it('shows foo page', () => {
11+
cy.visit('/foo');
12+
cy.title().should('equal', 'Foo | Dumber Demo');
13+
cy.get('router-view').contains('Foo!');
14+
});
15+
16+
it('navigates', () => {
17+
cy.visit('/');
18+
cy.get('.menu-link').contains('Foo').click();
19+
cy.location('pathname').should('equal', '/foo');
20+
cy.title().should('equal', 'Foo | Dumber Demo');
21+
cy.get('router-view').contains('Foo!');
22+
23+
cy.get('.menu-link').contains('Home').click();
24+
cy.title().should('equal', 'Home | Dumber Demo');
25+
cy.get('router-view').contains('Home!');
26+
cy.location('pathname').should('equal', '/');
27+
});
28+
});

common/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ Thumbs.db
1212
# Compiled files
1313
/dist
1414
/index.html
15+
16+
// @if cypress
17+
/cypress/videos
18+
/cypress/screenshots
19+
// @endif

common/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
"@babel/core": "^7.4.3",
99
"@babel/preset-env": "^7.4.3",
1010
"@babel/plugin-syntax-dynamic-import": "7.2.0",
11-
"babel-eslint": "^10.0.1",
12-
"eslint": "^5.16.0",
1311
"gulp-babel": "^8.0.0",
1412
"regenerator-runtime": "0.13.2",
1513
// @endif
1614

15+
// @if babel || cypress
16+
"babel-eslint": "^10.0.1",
17+
"eslint": "^5.16.0",
18+
// @endif
19+
1720
// @if typescript
1821
"typescript": "^3.4.5",
1922
"gulp-typescript": "^5.0.1",

cypress/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Cypress e2e test
2+
All e2e tests are in `cypress/integration/`.
3+
4+
First, run the app in dev mode
5+
```
6+
npx gulp
7+
```
8+
9+
Then run e2e tests with
10+
11+
```
12+
npx cypress run
13+
```
14+
15+
Note if your dev app is not running on port 3000, you need to modify `cypress.json` to update dev app port.
16+
17+
To run Cypress interactively, do
18+
19+
```
20+
npx cypress open
21+
```
22+
23+
For more information, visit https://www.cypress.io

cypress/cypress.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"baseUrl": "http://localhost:3000"
3+
}

cypress/cypress/.eslintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"root": true,
3+
"extends": "eslint:recommended",
4+
"parser": "babel-eslint",
5+
"parserOptions": {
6+
"ecmaVersion": 6,
7+
"sourceType": "module",
8+
"ecmaFeatures": {
9+
"legacyDecorators": true
10+
}
11+
},
12+
"rules": {
13+
"no-console": 0
14+
},
15+
"env": {
16+
"es6": true,
17+
"browser": true
18+
}
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/cypress/plugins/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ***********************************************************
2+
// This example plugins/index.js can be used to load plugins
3+
//
4+
// You can change the location of this file or turn off loading
5+
// the plugins file with the 'pluginsFile' configuration option.
6+
//
7+
// You can read more here:
8+
// https://on.cypress.io/plugins-guide
9+
// ***********************************************************
10+
11+
// This function is called when a project is opened or re-opened (e.g. due to
12+
// the project's config changing)
13+
14+
module.exports = (on, config) => {
15+
// `on` is used to hook into various events Cypress emits
16+
// `config` is the resolved Cypress config
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This is will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

cypress/cypress/support/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

0 commit comments

Comments
 (0)