@@ -10,14 +10,18 @@ Requires [Node](https://nodejs.org/en/) version 8 or above and Cypress v4.5.0+
1010
1111``` sh
1212# Install this plugin and test spec preprocessor
13- npm install --save-dev cypress-svelte-unit-test @bahmutov/cy-rollup
13+ npm install --save-dev cypress-svelte-unit-test
14+ # if Cypress is not installed already
15+ npx install --save-dev cypress
1416```
1517
16181 . Tell Cypress to use your ` rollup.config.js ` to bundle specs using [ cypress/plugins/index.js] ( cypress/plugins/index.js ) :
1719
1820``` js
1921module .exports = (on ) => {
20- on (' file:preprocessor' , require (' @bahmutov/cy-rollup' ))
22+ // @bahmutov/cy-rollup is already a dependency of cypress-react-unit-test
23+ const filePreprocessor = require (' @bahmutov/cy-rollup' )
24+ on (' file:preprocessor' , filePreprocessor ())
2125}
2226```
2327
@@ -33,6 +37,21 @@ module.exports = (on) => {
3337
3438See [ cypress.json] ( cypress.json ) in this project.
3539
40+ 3 . Write a test!
41+
42+ ``` js
43+ import HelloWorld from ' ./HelloWorld.svelte'
44+ import { mount } from ' cypress-svelte-unit-test'
45+ it (' shows greeting' , () => {
46+ mount (HelloWorld, {
47+ props: {
48+ name: ' World' ,
49+ },
50+ })
51+ cy .contains (' h1' , ' Hello World!' )
52+ })
53+ ```
54+
3655## Known issues
3756
3857- need to load images differently to transform relative paths
@@ -76,7 +95,9 @@ Add the plugin to your [cypress/plugins/index.js](cypress/plugins/index.js) file
7695
7796``` js
7897module .exports = (on , config ) => {
79- on (' file:preprocessor' , require (' @bahmutov/cy-rollup' ))
98+ const filePreprocessor = require (' @bahmutov/cy-rollup' )
99+ on (' file:preprocessor' , filePreprocessor ())
100+
80101 require (' @cypress/code-coverage/task' )(on, config)
81102 // IMPORTANT to return the config object
82103 // with the any changed environment variables
0 commit comments