File tree Expand file tree Collapse file tree 4 files changed +62
-2
lines changed Expand file tree Collapse file tree 4 files changed +62
-2
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.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
756Author: Gleb Bahmutov < ; gleb.bahmutov@gmail.com > ; © ; 2020
857
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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" : {
You can’t perform that action at this time.
0 commit comments