Skip to content

Commit a8ad240

Browse files
committed
add link to the blog post
1 parent 1e8963a commit a8ad240

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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

79
Assuming Cypress is a dev dependency

cypress.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"fixturesFolder": false,
3-
"testFiles": "*.md"
3+
"testFiles": "*.md",
4+
"viewportWidth": 500
45
}

cypress/integration/spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
```js
99
cy.contains('#hello', 'Hello')
10+
cy.get('#hello').should('have.text', 'Hello')
1011
```
1112
<!-- fiddle.end -->
1213

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)