File tree 13 files changed +513
-5
lines changed
13 files changed +513
-5
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,10 @@ jobs:
29
29
# we don't need Cypress to do the release
30
30
CYPRESS_INSTALL_BINARY : ' 0'
31
31
# trick semantic-release into thinking this is NOT a pull request
32
- # (under the hood env-ci is used)
33
- CIRCLE_PR_NUMBER :
34
- CIRCLE_PULL_REQUEST :
35
- CI_PULL_REQUEST :
32
+ # (under the hood the module env-ci is used to check if this is a PR )
33
+ CIRCLE_PR_NUMBER : ' '
34
+ CIRCLE_PULL_REQUEST : ' '
35
+ CI_PULL_REQUEST : ' '
36
36
steps :
37
37
- checkout
38
38
- node/with-cache :
Original file line number Diff line number Diff line change @@ -337,6 +337,7 @@ npm run dev:no:coverage
337
337
338
338
- [ examples/before-each-visit] ( examples/before-each-visit ) checks if code coverage correctly keeps track of code when doing ` cy.visit ` before each test
339
339
- [ examples/before-all-visit] ( examples/before-all-visit ) checks if code coverage works when ` cy.visit ` is made once in the ` before ` hook
340
+ - [ examples/ts-example] ( examples/ts-example ) uses Babel + Parcel to instrument and serve TypeScript file
340
341
341
342
### External examples
342
343
Original file line number Diff line number Diff line change
1
+ {
2
+ "plugins" : [" istanbul" ]
3
+ }
Original file line number Diff line number Diff line change
1
+ # example: ts-example
2
+
3
+ Code coverage for TypeScript code. See [ nyc TS support] ( https://github.com/istanbuljs/nyc#typescript-projects ) docs too.
4
+
5
+ Code is instrumented on the fly using [ .babelrc] ( .babelrc ) and Parcel to run it.
6
+
7
+ ## Use
8
+
9
+ - start the server and Cypress with ` npm run dev `
10
+ - run the Cypress tests
11
+ - look at the generated reports in folder ` coverage `
Original file line number Diff line number Diff line change
1
+ {
2
+ "baseUrl" : " http://localhost:1234" ,
3
+ "fixturesFolder" : false
4
+ }
Original file line number Diff line number Diff line change
1
+ /// <reference types="cypress" />
2
+ describe ( 'ts-example' , ( ) => {
3
+ beforeEach ( ( ) => {
4
+ cy . visit ( '/' )
5
+ } )
6
+
7
+ it ( 'calls add' , ( ) => {
8
+ cy . window ( )
9
+ . invoke ( 'add' , 2 , 3 )
10
+ . should ( 'equal' , 5 )
11
+ } )
12
+
13
+ it ( 'calls sub' , ( ) => {
14
+ cy . window ( )
15
+ . invoke ( 'sub' , 2 , 3 )
16
+ . should ( 'equal' , - 1 )
17
+ } )
18
+
19
+ it ( 'calls abs twice' , ( ) => {
20
+ cy . window ( )
21
+ . invoke ( 'abs' , 2 )
22
+ . should ( 'equal' , 2 )
23
+
24
+ cy . window ( )
25
+ . invoke ( 'abs' , - 5 )
26
+ . should ( 'equal' , 5 )
27
+ } )
28
+ } )
Original file line number Diff line number Diff line change
1
+ module . exports = ( on , config ) => {
2
+ on ( 'task' , require ( '../../../../task' ) )
3
+ }
Original file line number Diff line number Diff line change
1
+ import '../../../../support'
Original file line number Diff line number Diff line change
1
+ < body >
2
+ Page body
3
+ < script src ="main.ts "> </ script >
4
+ </ body >
Original file line number Diff line number Diff line change
1
+ const add = ( a : number , b : number ) => {
2
+ return a + b
3
+ }
4
+
5
+ const sub = ( a : number , b : number ) => {
6
+ return a - b
7
+ }
8
+
9
+ function abs ( x : number ) {
10
+ if ( x >= 0 ) {
11
+ return x
12
+ } else {
13
+ return - x
14
+ }
15
+ }
16
+
17
+ // @ts -ignore
18
+ window . add = add
19
+ // @ts -ignore
20
+ window . sub = sub
21
+ // @ts -ignore
22
+ window . abs = abs
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " example-before-each-visit" ,
3
+ "description" : " Getting code coverage when cy.visit is used in beforeEach hook" ,
4
+ "devDependencies" : {},
5
+ "nyc" : {
6
+ "extends" : " @istanbuljs/nyc-config-typescript" ,
7
+ "all" : true
8
+ },
9
+ "scripts" : {
10
+ "start" : " ../../node_modules/.bin/parcel serve index.html" ,
11
+ "build" : " ../../node_modules/.bin/parcel build index.html" ,
12
+ "serve" : " ../../node_modules/.bin/serve dist" ,
13
+ "cy:open" : " ../../node_modules/.bin/cypress open" ,
14
+ "coverage" : " ../../node_modules/.bin/nyc report --report-dir ./coverage --temp-dir .nyc_output --reporter=lcov" ,
15
+ "dev" : " ../../node_modules/.bin/start-test 1234 cy:open" ,
16
+ "dev:dist" : " CYPRESS_baseUrl=http://localhost:5000 ../../node_modules/.bin/start-test serve 5000 cy:open"
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments