Skip to content

Commit 55d1d2b

Browse files
committed
feat: basic cypress e2e tests
1 parent eb49334 commit 55d1d2b

File tree

17 files changed

+158
-15
lines changed

17 files changed

+158
-15
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ npx makes aurelia
2424
- [x] Basic app with FuseBox
2525
- [x] Basic app with dumber (successor of CLI built-in bundler. Doc WIP)
2626
- [ ] Basic unit test setup for jest, jasmine, mocha, tape, ava
27-
- [ ] Basic e2e test setup for cypress, protractor
27+
- [x] Basic e2e test setup for cypress
28+
- [ ] Basic e2e test setup for protractor
2829
- [ ] Aurelia convention support (boilerplate free like Aurelia v1) at bundler level
2930

3031
## Development

browserify/gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ function startServer(done) {
4040
browserSync.init({
4141
ghostMode: false,
4242
online: false,
43-
watch: true, // watch dist/bundle.js
4443
open: !process.env.CI,
44+
port: 9000,
4545
server: {
4646
baseDir: ['.'],
4747
middleware: [

cypress/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
## Cypress e2e test
3+
4+
All e2e tests are in `cypress/integration/`.
5+
// @if typescript
6+
Note the source code of the app and unit tests is in TypeScript, but e2e tests are in plain ESNext JavaScript. You can however [write e2e tests in TypeScript too for Cypress](https://docs.cypress.io/guides/tooling/typescript-support.html#Transpiling-TypeScript-test-files).
7+
// @endif
8+
9+
First, run the app in dev mode
10+
11+
npm start
12+
13+
Then run e2e tests in another terminal window with
14+
15+
npm run test:e2e
16+
17+
Note if your dev app is not running on port 9000, you need to modify `cypress.json` to update dev app port.
18+
19+
To run Cypress interactively, do
20+
21+
npx cypress open
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:9000"
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+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference types="Cypress" />
2+
3+
context('The app', () => {
4+
it('shows message', () => {
5+
cy.visit('/');
6+
cy.get('app>div').contains('Hello World!');
7+
});
8+
});

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)