diff --git a/INSTRUCTIONS.md b/INSTRUCTIONS.md index 85d1eb13..94f5701f 100644 --- a/INSTRUCTIONS.md +++ b/INSTRUCTIONS.md @@ -487,8 +487,10 @@ Now let's have it run on our codebase 1. In one terminal tab/window start the dev server `npm run dev`. Note this is running on port `8080` 2. Open `./cypress.json` and add `"baseUrl": "http://localhost:8080"` and `"integrationFolder": "cypress/e2e"` -3. Delete `./cypress/integration` and copy `../calculator.solution/e2e/calculator.js` to `./cypress/e2e/calculator.js` -4. Start cypress over again: `npx cypress open` and run the test. It passes! +3. `npm install --save-dev cypress-testing-library` +4. Update `cypress/support/index.js` to import `cypress-testing-library/add-commands` +5. Delete `./cypress/integration` and copy `../calculator.solution/e2e/calculator.js` to `./cypress/e2e/calculator.js` +6. Start cypress over again: `npx cypress open` and run the test. It passes! Now let's make this a script diff --git a/other/configuration/calculator.solution/cypress/e2e/calculator.js b/other/configuration/calculator.solution/cypress/e2e/calculator.js index c873451b..a3b4ee94 100644 --- a/other/configuration/calculator.solution/cypress/e2e/calculator.js +++ b/other/configuration/calculator.solution/cypress/e2e/calculator.js @@ -1,6 +1,15 @@ /* globals cy */ describe('calculator', () => { it('can visit the app', () => { - cy.visit('/') + cy + .visit('/') + .getByText(/^1$/) + .click() + .getByText(/^\+$/) + .click() + .getByText(/^2$/) + .click() + .getByText(/^=$/) + .click() }) }) diff --git a/other/configuration/calculator.solution/cypress/support/index.js b/other/configuration/calculator.solution/cypress/support/index.js index d68db96d..9f06be50 100644 --- a/other/configuration/calculator.solution/cypress/support/index.js +++ b/other/configuration/calculator.solution/cypress/support/index.js @@ -15,6 +15,7 @@ // Import commands.js using ES2015 syntax: import './commands' +import 'cypress-testing-library/add-commands' // Alternatively you can use CommonJS syntax: // require('./commands') diff --git a/other/configuration/calculator.solution/package.json b/other/configuration/calculator.solution/package.json index 65824f04..70acfeb5 100644 --- a/other/configuration/calculator.solution/package.json +++ b/other/configuration/calculator.solution/package.json @@ -29,6 +29,7 @@ "babel-preset-react": "^6.24.1", "css-loader": "^0.28.11", "cypress": "^2.1.0", + "cypress-testing-library": "^1.0.0", "file-loader": "^1.1.11", "identity-obj-proxy": "^3.0.0", "jest": "^22.4.3", diff --git a/package.json b/package.json index 4292e070..91addb0f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "cross-env": "^5.1.3", "cross-spawn": "^6.0.4", "cypress": "^2.0.2", - "cypress-testing-library": "^1.0.0", + "cypress-testing-library": "^1.0.1", "doctoc": "^1.3.0", "eslint": "^4.18.0", "eslint-config-kentcdodds": "^13.0.1",