File tree 5 files changed +17
-4
lines changed
other/configuration/calculator.solution
5 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -487,8 +487,10 @@ Now let's have it run on our codebase
487
487
488
488
1 . In one terminal tab/window start the dev server ` npm run dev ` . Note this is running on port ` 8080 `
489
489
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!
492
494
493
495
Now let's make this a script
494
496
Original file line number Diff line number Diff line change 1
1
/* globals cy */
2
2
describe ( 'calculator' , ( ) => {
3
3
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 ( )
5
14
} )
6
15
} )
Original file line number Diff line number Diff line change 15
15
16
16
// Import commands.js using ES2015 syntax:
17
17
import './commands'
18
+ import 'cypress-testing-library/add-commands'
18
19
19
20
// Alternatively you can use CommonJS syntax:
20
21
// require('./commands')
Original file line number Diff line number Diff line change 29
29
"babel-preset-react" : " ^6.24.1" ,
30
30
"css-loader" : " ^0.28.11" ,
31
31
"cypress" : " ^2.1.0" ,
32
+ "cypress-testing-library" : " ^1.0.0" ,
32
33
"file-loader" : " ^1.1.11" ,
33
34
"identity-obj-proxy" : " ^3.0.0" ,
34
35
"jest" : " ^22.4.3" ,
Original file line number Diff line number Diff line change 46
46
"cross-env" : " ^5.1.3" ,
47
47
"cross-spawn" : " ^6.0.4" ,
48
48
"cypress" : " ^2.0.2" ,
49
- "cypress-testing-library" : " ^1.0.0 " ,
49
+ "cypress-testing-library" : " ^1.0.1 " ,
50
50
"doctoc" : " ^1.3.0" ,
51
51
"eslint" : " ^4.18.0" ,
52
52
"eslint-config-kentcdodds" : " ^13.0.1" ,
You can’t perform that action at this time.
0 commit comments