File tree Expand file tree Collapse file tree 4 files changed +11
-1
lines changed Expand file tree Collapse file tree 4 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 22[ ![ ci status] [ ci image ]] [ ci url ] [ ![ badges status] [ badges image ]] [ badges url ] [ ![ renovate-app badge] [ renovate-badge ]] [ renovate-app ] ![ cypress version] ( https://img.shields.io/badge/cypress-6.6.0-brightgreen ) ![ @cypress/fiddle version] ( https://img.shields.io/badge/@cypress/fiddle-1.19.0-brightgreen )
33> Use Markdown files as Cypress specs
44
5+ Read [ Write Cypress Markdown Preprocessor] ( https://glebbahmutov.com/blog/write-cypress-preprocessor/ )
6+
57## Install
68
79Assuming Cypress is a dev dependency
Original file line number Diff line number Diff line change 11{
22 "fixturesFolder" : false ,
3- "testFiles" : " *.md"
3+ "testFiles" : " *.md" ,
4+ "viewportWidth" : 500
45}
Original file line number Diff line number Diff line change 77
88``` js
99cy .contains (' #hello' , ' Hello' )
10+ cy .get (' #hello' ).should (' have.text' , ' Hello' )
1011```
1112<!-- fiddle.end -->
1213
Original file line number Diff line number Diff line change @@ -76,10 +76,14 @@ const mdPreprocessor = (file) => {
7676 if ( shouldWatch ) {
7777 debug ( 'watching the file %s' , filePath )
7878
79+ // start bundling the first time
7980 bundled [ filePath ] = bundleMdFile ( filePath , outputPath )
8081
82+ // and start watching the input Markdown file
8183 const watcher = chokidar . watch ( filePath )
8284 watcher . on ( 'change' , ( ) => {
85+ // if the Markdown file changes, we want to rebundle it
86+ // and tell the Test Runner to run the tests again
8387 debug ( 'file %s has changed' , filePath )
8488 bundled [ filePath ] = bundleMdFile ( filePath , outputPath )
8589 bundled [ filePath ] . then ( ( ) => {
@@ -88,6 +92,7 @@ const mdPreprocessor = (file) => {
8892 } )
8993 } )
9094
95+ // when the test runner closes this spec
9196 file . on ( 'close' , ( ) => {
9297 debug ( 'file %s close, removing bundle promise' , filePath )
9398 delete bundled [ filePath ]
@@ -97,6 +102,7 @@ const mdPreprocessor = (file) => {
97102 return bundled [ filePath ]
98103 }
99104
105+ // non-interactive mode
100106 bundled [ filePath ] = bundleMdFile ( filePath , outputPath )
101107 return bundled [ filePath ]
102108}
You can’t perform that action at this time.
0 commit comments