Skip to content

Commit 8f530e7

Browse files
authored
fix: upgraded cypress-fiddle (#137)
* feat: hide js block * fix: bump cypress fiddle * disable verbose logger * add cypress-split * update the workflow * bump fiddle
1 parent 9b5b468 commit 8f530e7

File tree

7 files changed

+2548
-169
lines changed

7 files changed

+2548
-169
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,19 @@ name: ci
22
on: push
33
jobs:
44
test:
5+
# https://github.com/bahmutov/cypress-workflows
6+
uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v1
7+
with:
8+
n: 3
9+
command: npm test
10+
11+
release:
12+
needs: 'test'
513
runs-on: ubuntu-20.04
614
steps:
715
- name: Checkout 🛎
816
uses: actions/checkout@v3
917

10-
# Node > 16
11-
# npm > 8
12-
- name: Print Node version 🖨
13-
run: |
14-
node -v
15-
npm -v
16-
17-
- name: Run tests 🧪
18-
uses: cypress-io/github-action@v5
19-
with:
20-
command: npm t
21-
22-
- name: Test exporting Markdown to JavaScript 🖨
23-
run: |
24-
node ./bin/export-fiddles cypress/e2e/skip.md
25-
cat cypress/e2e/skip.js
26-
# TODO: confirm the exported JavaScript file
27-
2818
- name: Semantic Release 🚀
2919
uses: cycjimmy/semantic-release-action@v3
3020
if: github.ref == 'refs/heads/main'

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,28 @@ You can hide the HTML code block from the source view, yet still have it part of
131131

132132
<!-- fiddle-end -->
133133

134+
### Hide JavaScript code block
135+
136+
You can run but hide parts of the JavaScript code
137+
138+
<!-- fiddle Hide the first JS block -->
139+
140+
```html
141+
<div id="greeting">Hello</div>
142+
```
143+
144+
```js hide
145+
// the test code will run but not shown to the user
146+
cy.log('this block is hidden')
147+
```
148+
149+
```js
150+
// this code will be shown to the user
151+
cy.get('div#greeting').should('have.text', 'Hello')
152+
```
153+
154+
<!-- fiddle-end -->
155+
134156
### CSS block
135157

136158
You can add CSS to be applied to the HTML application. The CSS block is not shown on the output page.

cypress.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const { defineConfig } = require('cypress')
2+
// https://github.com/bahmutov/cypress-split
3+
const cypressSplit = require('cypress-split')
24

35
// in the user project it would be
46
// const mdPreprocessor = require('cypress-markdown-preprocessor')
@@ -11,6 +13,7 @@ module.exports = defineConfig({
1113
// We've imported your old cypress plugins here.
1214
// You may want to clean this up later by importing these.
1315
setupNodeEvents(on, config) {
16+
cypressSplit(on, config)
1417
on('file:preprocessor', mdPreprocessor)
1518
return config
1619
},

cypress/e2e/hide-js.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,29 @@ cy.get('div#greeting').should('have.text', 'Hello')
1111
```
1212

1313
<!-- fiddle-end -->
14+
15+
## Partial code
16+
17+
This test has several JS code blocks, and some of them are hidden
18+
19+
<!-- fiddle only some JavaScript source is shown -->
20+
21+
```html
22+
<div id="greeting">Hello</div>
23+
```
24+
25+
```js hide
26+
cy.log('this block is hidden')
27+
```
28+
29+
Only this code block should be shown on the page
30+
31+
```js
32+
cy.get('div#greeting').should('have.text', 'Hello')
33+
```
34+
35+
```js hide
36+
cy.log('this block is also hidden')
37+
```
38+
39+
<!-- fiddle-end -->

0 commit comments

Comments
 (0)