mirror of
https://github.com/datashard/snapshot.git
synced 2024-11-21 21:52:28 +00:00
chore: add cypress e2e tests, close #5
This commit is contained in:
parent
6360114dd8
commit
d3d1bc3c54
9 changed files with 100 additions and 1 deletions
|
@ -10,6 +10,7 @@ install:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- npm run test
|
- npm run test
|
||||||
|
- npm run cypress:run
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- npm run semantic-release
|
- npm run semantic-release
|
||||||
|
|
1
cypress.json
Normal file
1
cypress.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{}
|
5
cypress/fixtures/example.json
Normal file
5
cypress/fixtures/example.json
Normal file
|
@ -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"
|
||||||
|
}
|
25
cypress/integration/spec.js
Normal file
25
cypress/integration/spec.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/* eslint-env mocha */
|
||||||
|
/* global cy */
|
||||||
|
describe('@cypress/snapshot', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io')
|
||||||
|
})
|
||||||
|
|
||||||
|
context('simple types', () => {
|
||||||
|
it('works with objects', () => {
|
||||||
|
cy.wrap({ foo: 42 }).snapshot()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('works with numbers', () => {
|
||||||
|
cy.wrap(42).snapshot()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('works with strings', () => {
|
||||||
|
cy.wrap('foo-bar').snapshot()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('works with arrays', () => {
|
||||||
|
cy.wrap([1, 2, 3]).snapshot()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
17
cypress/plugins/index.js
Normal file
17
cypress/plugins/index.js
Normal file
|
@ -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
|
||||||
|
}
|
2
cypress/support/commands.js
Normal file
2
cypress/support/commands.js
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// register .snapshot() command
|
||||||
|
require('../..')()
|
20
cypress/support/index.js
Normal file
20
cypress/support/index.js
Normal file
|
@ -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')
|
|
@ -64,7 +64,9 @@
|
||||||
"unit": "mocha src/*-spec.js",
|
"unit": "mocha src/*-spec.js",
|
||||||
"unused-deps": "dependency-check --unused --no-dev . --entry src/add-initial-snapshot-file.js",
|
"unused-deps": "dependency-check --unused --no-dev . --entry src/add-initial-snapshot-file.js",
|
||||||
"postinstall": "node src/add-initial-snapshot-file.js",
|
"postinstall": "node src/add-initial-snapshot-file.js",
|
||||||
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post"
|
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post",
|
||||||
|
"cypress:open": "cypress open",
|
||||||
|
"cypress:run": "cypress run"
|
||||||
},
|
},
|
||||||
"release": {
|
"release": {
|
||||||
"analyzeCommits": "simple-commit-message",
|
"analyzeCommits": "simple-commit-message",
|
||||||
|
@ -72,6 +74,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ban-sensitive-files": "1.9.2",
|
"ban-sensitive-files": "1.9.2",
|
||||||
|
"cypress": "1.1.4",
|
||||||
"debug": "3.1.0",
|
"debug": "3.1.0",
|
||||||
"dependency-check": "2.9.1",
|
"dependency-check": "2.9.1",
|
||||||
"deps-ok": "1.2.1",
|
"deps-ok": "1.2.1",
|
||||||
|
|
25
snapshots.js
Normal file
25
snapshots.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
module.exports = {
|
||||||
|
"@cypress/snapshot": {
|
||||||
|
"simple types": {
|
||||||
|
"works with objects": {
|
||||||
|
"1": {
|
||||||
|
"foo": 42
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"works with numbers": {
|
||||||
|
"1": 42
|
||||||
|
},
|
||||||
|
"works with strings": {
|
||||||
|
"1": "foo-bar"
|
||||||
|
},
|
||||||
|
"works with arrays": {
|
||||||
|
"1": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"__version": "1.1.4"
|
||||||
|
}
|
Loading…
Reference in a new issue