File tree Expand file tree Collapse file tree 7 files changed +87
-4
lines changed Expand file tree Collapse file tree 7 files changed +87
-4
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "fixturesFolder" : false ,
3+ "testFiles" : " *.md"
4+ }
Original file line number Diff line number Diff line change 1+ # Cypress.io end-to-end tests
2+
3+ [ Cypress.io] ( https://www.cypress.io ) is an open source, MIT licensed end-to-end test runner
4+
5+ ## Folder structure
6+
7+ These folders hold end-to-end tests and supporting files for the Cypress Test Runner.
8+
9+ - [ integration] ( integration ) holds the actual test files, [ read more] ( https://on.cypress.io/writing-and-organizing-tests )
10+ - [ plugins] ( plugins ) allow you to customize how tests are loaded, [ read more] ( https://on.cypress.io/plugins )
11+ - [ support] ( support ) file runs before all tests and is a great place to write or load additional custom commands, [ read more] ( https://on.cypress.io/writing-and-organizing-tests#Support-file )
12+
13+ ## ` cypress.json ` file
14+
15+ You can configure project options in the [ ../cypress.json] ( ../cypress.json ) file, see [ Cypress configuration doc] ( https://on.cypress.io/configuration ) .
16+
17+ ## More information
18+
19+ - [ https://github.com/cypress.io/cypress ] ( https://github.com/cypress.io/cypress )
20+ - [ https://docs.cypress.io/ ] ( https://docs.cypress.io/ )
21+ - [ Writing your first Cypress test] ( http://on.cypress.io/intro )
Original file line number Diff line number Diff line change 1+ # Cypress Markdown spec
2+
3+ <!-- fiddle Example -->
4+ ``` html
5+ <div id =" parent" >
6+ <div id =" first" >A new div will appear in 2 seconds</div >
7+ </div >
8+ <script >
9+ setTimeout (() => {
10+ const div = document .getElementById (' parent' )
11+ const newDiv = document .createElement (' second' )
12+ newDiv .textContent = ' second div'
13+ newDiv .id = ' second'
14+ div .appendChild (newDiv)
15+ }, 2000 )
16+ </script >
17+ ```
18+
19+ ``` js
20+ cy .get (' #first' ).should (' be.visible' )
21+ cy .get (' #second' ).should (' have.text' , ' second div' )
22+ ```
23+ <!-- fiddle.end -->
Original file line number Diff line number Diff line change 1+ /// <reference types="cypress" />
2+
3+ // This function is called when a project is opened or re-opened (e.g. due to
4+ // the project's config changing)
5+
6+ // in the user project it would be
7+ // const mdPreprocessor = require('cypress-markdown-preprocessor')
8+ const mdPreprocessor = require ( '../..' )
9+
10+ /**
11+ * @type {Cypress.PluginConfig }
12+ */
13+ module . exports = ( on , config ) => {
14+ // `on` is used to hook into various events Cypress emits
15+ // `config` is the resolved Cypress config
16+ on ( 'file:preprocessor' , mdPreprocessor )
17+ }
Original file line number Diff line number Diff line change 1+ // ***********************************************************
2+ // This example support/index.js is processed and
3+ // loaded automatically before your test files.
4+ //
5+ // This is a great place to put global configuration and
6+ // behavior that modifies Cypress.
7+ //
8+ // You can change the location of this file or turn off
9+ // automatically serving support files with the
10+ // 'supportFile' configuration option.
11+ //
12+ // You can read more here:
13+ // https://on.cypress.io/configuration
14+ // ***********************************************************
Original file line number Diff line number Diff line change 22 "name" : " cypress-markdown-preprocessor" ,
33 "version" : " 1.0.0" ,
44 "description" : " Use Markdown files as Cypress specs" ,
5- "main" : " index.js" ,
5+ "main" : " src/ index.js" ,
66 "scripts" : {
7+ "cy:open" : " cypress open" ,
78 "test" : " cypress run"
89 },
910 "repository" : {
Original file line number Diff line number Diff line change @@ -6,8 +6,11 @@ const tempWrite = require('temp-write')
66const cyBrowserify = require ( '@cypress/browserify-preprocessor' ) ( )
77const debug = require ( 'debug' ) ( 'cypress-markdown-preprocessor' )
88const mdUtils = require ( './markdown-utils' )
9- const testExamplesPath = require ( '@cypress/fiddle' )
109
10+ // when a temporary file is written, it is placed outside the current folder
11+ // thus finding the "@cypress/fiddle" module using the regular Node module resolution
12+ // is impossible. Just resolve the path once and require it directly later.
13+ const fiddleModulePath = require . resolve ( '@cypress/fiddle' )
1114/**
1215 Parses Markdown file looking for special fiddle comments. If found,
1316 creates separate tests from them. If processing ".js" or ".coffee" files just
@@ -37,9 +40,9 @@ const mdPreprocessor = (file) => {
3740 }
3841
3942 const specSource = source `
43+ const { testExamples } = require('${ fiddleModulePath } ');
4044 const fiddles = ${ createTestsText } ;
41- import { testExamples } from '${ testExamplesPath } '
42- testExamples(fiddles)
45+ testExamples(fiddles);
4346 `
4447 // console.log(specSource)
4548 const writtenTempFilename = tempWrite . sync (
You can’t perform that action at this time.
0 commit comments