Skip to content

Commit 72dfe9d

Browse files
committed
feat: finish the readme
1 parent 8100fd2 commit 72dfe9d

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,56 @@
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.1.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-
### Small print
5+
## Install
6+
7+
Assuming Cypress is a dev dependency
8+
9+
```
10+
npm i -D cypress-markdown-preprocessor
11+
# or
12+
yarn add -D cypress-markdown-preprocessor
13+
```
14+
15+
Add to your Cypress plugins file
16+
17+
```js
18+
// cypress/plugins/index.js
19+
const mdPreprocessor = require('cypress-markdown-preprocessor')
20+
module.exports = (on, config) => {
21+
on('file:preprocessor', mdPreprocessor)
22+
}
23+
```
24+
25+
Set the [`testFiles`](https://on.cypress.io/configuration) to use Markdown files as specs
26+
27+
```json
28+
{
29+
"testFiles": "*.md"
30+
}
31+
```
32+
33+
## Use
34+
35+
Write Markdown spec files including "fiddle" comments. Each fiddle comment will be extracted into own test.
36+
37+
<!-- fiddle Example -->
38+
```html
39+
<div id="hello">Hello</div>
40+
```
41+
42+
```js
43+
cy.contains('#hello', 'Hello')
44+
```
45+
<!-- fiddle.end -->
46+
47+
The "html" block is optional.
48+
49+
![Example test](images/example.png)
50+
51+
Note: after extracting the tests, this preprocessor sets [@cypress/fiddle](https://github.com/cypress-io/cypress-fiddle) to run them.
52+
53+
54+
## Small print
655

756
Author: Gleb Bahmutov &lt;gleb.bahmutov@gmail.com&gt; &copy; 2020
857

cypress/integration/spec.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
<!-- fiddle Example -->
44
```html
5+
<div id="hello">Hello</div>
6+
```
7+
8+
```js
9+
cy.contains('#hello', 'Hello')
10+
```
11+
<!-- fiddle.end -->
12+
13+
<!-- fiddle Another example -->
14+
```html
515
<div id="parent">
616
<div id="first">A new div will appear in 2 seconds</div>
717
</div>

images/example.png

144 KB
Loading

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"version": "0.0.0-development",
44
"description": "Use Markdown files as Cypress specs",
55
"main": "src/index.js",
6+
"files": ["src"],
67
"scripts": {
78
"cy:open": "cypress open",
89
"cy:run": "cypress run",
9-
"test": "cypress-expect run --passing 1",
10+
"test": "cypress-expect run --min-passing 2",
1011
"semantic-release": "semantic-release"
1112
},
1213
"repository": {

0 commit comments

Comments
 (0)