diff --git a/.travis.yml b/.travis.yml index fc9fd4c..5dc7435 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ install: script: - npm run test + - npm run cypress:run after_success: - npm run semantic-release diff --git a/cypress.json b/cypress.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/cypress.json @@ -0,0 +1 @@ +{} diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json new file mode 100644 index 0000000..da18d93 --- /dev/null +++ b/cypress/fixtures/example.json @@ -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" +} \ No newline at end of file diff --git a/cypress/integration/spec.js b/cypress/integration/spec.js new file mode 100644 index 0000000..40bc90c --- /dev/null +++ b/cypress/integration/spec.js @@ -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() + }) + }) +}) diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js new file mode 100644 index 0000000..fd170fb --- /dev/null +++ b/cypress/plugins/index.js @@ -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 +} diff --git a/cypress/support/commands.js b/cypress/support/commands.js new file mode 100644 index 0000000..97ae1ec --- /dev/null +++ b/cypress/support/commands.js @@ -0,0 +1,2 @@ +// register .snapshot() command +require('../..')() diff --git a/cypress/support/index.js b/cypress/support/index.js new file mode 100644 index 0000000..d68db96 --- /dev/null +++ b/cypress/support/index.js @@ -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') diff --git a/package.json b/package.json index d4c412f..11acc0e 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,9 @@ "unit": "mocha src/*-spec.js", "unused-deps": "dependency-check --unused --no-dev . --entry 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": { "analyzeCommits": "simple-commit-message", @@ -72,6 +74,7 @@ }, "devDependencies": { "ban-sensitive-files": "1.9.2", + "cypress": "1.1.4", "debug": "3.1.0", "dependency-check": "2.9.1", "deps-ok": "1.2.1", diff --git a/snapshots.js b/snapshots.js new file mode 100644 index 0000000..4049926 --- /dev/null +++ b/snapshots.js @@ -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" +}