Skip to content

Commit

Permalink
update cypress config stuff and cypress-testing-library
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Apr 19, 2018
1 parent d8a3741 commit 0591e7b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
6 changes: 4 additions & 2 deletions INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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')
1 change: 1 addition & 0 deletions other/configuration/calculator.solution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0591e7b

Please sign in to comment.