From 7d3c8daf07226a153c7a81d075b8cb5354ff5e17 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Wed, 10 Oct 2018 12:36:43 +0100 Subject: [PATCH] Install cypress --- .eslintrc | 35 ++++++++++++++++++++--------- cypress.json | 3 +++ cypress/fixtures/example.json | 5 +++++ cypress/integration/choices_spec.js | 12 ++++++++++ cypress/plugins/index.js | 17 ++++++++++++++ cypress/support/commands.js | 25 +++++++++++++++++++++ cypress/support/index.js | 20 +++++++++++++++++ package.json | 5 ++++- 8 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 cypress.json create mode 100644 cypress/fixtures/example.json create mode 100644 cypress/integration/choices_spec.js create mode 100644 cypress/plugins/index.js create mode 100644 cypress/support/commands.js create mode 100644 cypress/support/index.js diff --git a/.eslintrc b/.eslintrc index 454b853..78d60d5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -5,7 +5,8 @@ "prettier" ], "plugins": [ - "prettier" + "prettier", + "cypress" ], "env": { "es6": true, @@ -22,16 +23,30 @@ "afterEach": true }, "rules": { - "import/no-extraneous-dependencies": ["error", { - "devDependencies": true - }], - "no-console": ["warn", { "allow": ["warn", "error"] }], + "import/no-extraneous-dependencies": [ + "error", + { + "devDependencies": true + } + ], + "no-console": [ + "warn", + { + "allow": [ + "warn", + "error" + ] + } + ], "no-plusplus": "off", "no-unused-expressions": "off", "no-underscore-dangle": "off", - "prettier/prettier": ["error", { - "singleQuote": true, - "trailingComma": "all" - }] + "prettier/prettier": [ + "error", + { + "singleQuote": true, + "trailingComma": "all" + } + ] } -} +} \ No newline at end of file diff --git a/cypress.json b/cypress.json new file mode 100644 index 0000000..6fda274 --- /dev/null +++ b/cypress.json @@ -0,0 +1,3 @@ +{ + "baseUrl": "http://localhost:3001" +} \ No newline at end of file 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/choices_spec.js b/cypress/integration/choices_spec.js new file mode 100644 index 0000000..94de2e7 --- /dev/null +++ b/cypress/integration/choices_spec.js @@ -0,0 +1,12 @@ +describe('Choices', () => { + describe('text element', () => { + it('works', () => { + cy.visit('/'); + expect(true).to.equal(true); + }); + }); + + describe('select-one element', () => {}); + + describe('select-multiple element', () => {}); +}); 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..c1f5a77 --- /dev/null +++ b/cypress/support/commands.js @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add("login", (email, password) => { ... }) +// +// +// -- This is a child command -- +// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This is will overwrite an existing command -- +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) 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 c9f733a..c50461f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "coverage": "nyc npm run test", "test": "mocha --require ./config/test.js --compilers js:babel-core/register \"./src/**/**/**/**/*.test.js\"", "test:watch": "npm run test -- --watch --inspect=5556", + "cypress": "$(npm bin)/cypress run", "css:watch": "nodemon -e scss -x \"npm run css:build\"", "css:build": "npm run css:sass -s && npm run css:prefix -s && npm run css:min -s", "css:sass": "node-sass --output-style expanded --include-path scss src/styles/base.scss public/assets/styles/base.css && node-sass --output-style expanded --include-path scss src/styles/choices.scss public/assets/styles/choices.css", @@ -49,10 +50,12 @@ "chai": "^4.1.0", "concurrently": "^3.1.0", "csso": "^1.8.2", + "cypress": "^3.1.0", "eslint": "^3.19.0", "eslint-config-airbnb": "^15.1.0", "eslint-config-prettier": "^2.9.0", "eslint-loader": "^1.5.0", + "eslint-plugin-cypress": "^2.0.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-prettier": "^2.6.0", @@ -64,6 +67,7 @@ "node-sass": "^3.4.2", "nodemon": "^1.9.1", "nyc": "^11.0.3", + "opn": "^5.1.0", "postcss-cli": "^2.5.1", "prettier": "^1.13.0", "sinon": "^2.4.0", @@ -79,7 +83,6 @@ "custom-event-polyfill": "^0.3.0", "deepmerge": "^2.2.1", "fuse.js": "^3.1.0", - "opn": "^5.1.0", "redux": "^3.3.1" }, "npmName": "choices.js",