Skip to content
This repository was archived by the owner on Oct 13, 2022. It is now read-only.

Commit f4b72b4

Browse files
committed
add tests (#1)
1 parent 4ff205d commit f4b72b4

File tree

10 files changed

+124
-2
lines changed

10 files changed

+124
-2
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
node_modules
33
.sapper
4-
yarn.lock
4+
yarn.lock
5+
cypress/screenshots

.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- "stable"
5+
env:
6+
global:
7+
- BUILD_TIMEOUT=10000
8+
install: npm install
9+

appveyor.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "{build}"
2+
3+
shallow_clone: true
4+
5+
init:
6+
- git config --global core.autocrlf false
7+
8+
environment:
9+
matrix:
10+
# node.js
11+
- nodejs_version: stable
12+
13+
install:
14+
- ps: Install-Product node $env:nodejs_version
15+
- npm install

cypress.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"baseUrl": "http://localhost:3000",
3+
"videoRecording": false
4+
}

cypress/fixtures/example.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/integration/spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
describe('Sapper template app', () => {
2+
beforeEach(() => {
3+
cy.visit('/')
4+
});
5+
6+
it('has the correct <h1>', () => {
7+
cy.contains('h1', 'Great success!')
8+
});
9+
10+
it('navigates to /about', () => {
11+
cy.get('nav a').contains('about').click();
12+
cy.url().should('include', '/about');
13+
});
14+
15+
it('navigates to /blog', () => {
16+
cy.get('nav a').contains('blog').click();
17+
cy.url().should('include', '/blog');
18+
});
19+
});

cypress/plugins/index.js

+17
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+
}

cypress/support/commands.js

+25
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/support/index.js

+20
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')

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"version": "0.0.1",
55
"scripts": {
66
"dev": "node server.js",
7-
"start": "cross-env NODE_ENV=production node server.js"
7+
"start": "cross-env NODE_ENV=production node server.js",
8+
"cy:run": "cypress run",
9+
"cy:open": "cypress open",
10+
"test": "run-p --race dev cy:run"
811
},
912
"dependencies": {
1013
"compression": "^1.7.1",
@@ -15,11 +18,15 @@
1518
"glob": "^7.1.2",
1619
"marked": "^0.3.7",
1720
"node-fetch": "^1.7.3",
21+
"npm-run-all": "^4.1.2",
1822
"sapper": "^0.1.1",
1923
"serve-static": "^1.13.1",
2024
"style-loader": "^0.19.0",
2125
"svelte": "^1.49.1",
2226
"svelte-loader": "^2.2.1",
2327
"uglifyjs-webpack-plugin": "^1.1.2"
28+
},
29+
"devDependencies": {
30+
"cypress": "^1.2.0"
2431
}
2532
}

0 commit comments

Comments
 (0)