Skip to content

Commit 0591e7b

Browse files
author
Kent C. Dodds
committed
update cypress config stuff and cypress-testing-library
1 parent d8a3741 commit 0591e7b

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

INSTRUCTIONS.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,10 @@ Now let's have it run on our codebase
487487

488488
1. In one terminal tab/window start the dev server `npm run dev`. Note this is running on port `8080`
489489
2. Open `./cypress.json` and add `"baseUrl": "http://localhost:8080"` and `"integrationFolder": "cypress/e2e"`
490-
3. Delete `./cypress/integration` and copy `../calculator.solution/e2e/calculator.js` to `./cypress/e2e/calculator.js`
491-
4. Start cypress over again: `npx cypress open` and run the test. It passes!
490+
3. `npm install --save-dev cypress-testing-library`
491+
4. Update `cypress/support/index.js` to import `cypress-testing-library/add-commands`
492+
5. Delete `./cypress/integration` and copy `../calculator.solution/e2e/calculator.js` to `./cypress/e2e/calculator.js`
493+
6. Start cypress over again: `npx cypress open` and run the test. It passes!
492494

493495
Now let's make this a script
494496

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
/* globals cy */
22
describe('calculator', () => {
33
it('can visit the app', () => {
4-
cy.visit('/')
4+
cy
5+
.visit('/')
6+
.getByText(/^1$/)
7+
.click()
8+
.getByText(/^\+$/)
9+
.click()
10+
.getByText(/^2$/)
11+
.click()
12+
.getByText(/^=$/)
13+
.click()
514
})
615
})

other/configuration/calculator.solution/cypress/support/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
// Import commands.js using ES2015 syntax:
1717
import './commands'
18+
import 'cypress-testing-library/add-commands'
1819

1920
// Alternatively you can use CommonJS syntax:
2021
// require('./commands')

other/configuration/calculator.solution/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"babel-preset-react": "^6.24.1",
3030
"css-loader": "^0.28.11",
3131
"cypress": "^2.1.0",
32+
"cypress-testing-library": "^1.0.0",
3233
"file-loader": "^1.1.11",
3334
"identity-obj-proxy": "^3.0.0",
3435
"jest": "^22.4.3",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"cross-env": "^5.1.3",
4747
"cross-spawn": "^6.0.4",
4848
"cypress": "^2.0.2",
49-
"cypress-testing-library": "^1.0.0",
49+
"cypress-testing-library": "^1.0.1",
5050
"doctoc": "^1.3.0",
5151
"eslint": "^4.18.0",
5252
"eslint-config-kentcdodds": "^13.0.1",

0 commit comments

Comments
 (0)