File tree Expand file tree Collapse file tree 13 files changed +513
-5
lines changed Expand file tree Collapse file tree 13 files changed +513
-5
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,10 @@ jobs:
2929 # we don't need Cypress to do the release
3030 CYPRESS_INSTALL_BINARY : ' 0'
3131 # 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 : ' '
3636 steps :
3737 - checkout
3838 - node/with-cache :
Original file line number Diff line number Diff line change @@ -337,6 +337,7 @@ npm run dev:no:coverage
337337
338338- [ examples/before-each-visit] ( examples/before-each-visit ) checks if code coverage correctly keeps track of code when doing ` cy.visit ` before each test
339339- [ 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
340341
341342### External examples
342343
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
You can’t perform that action at this time.
0 commit comments