Skip to content

Commit cd19df1

Browse files
committed
feat: move cy-rollup to production dependencies
BREAKING CHANGE: no need to install separate Rollup bundler, it is already included
1 parent a7b83ae commit cd19df1

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1618
1. Tell Cypress to use your `rollup.config.js` to bundle specs using [cypress/plugins/index.js](cypress/plugins/index.js):
1719

1820
```js
1921
module.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

3438
See [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
7897
module.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

cypress/plugins/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = (on, config) => {
22
// https://github.com/bahmutov/cy-rollup
3-
on('file:preprocessor', require('@bahmutov/cy-rollup'))
3+
const filePreprocessor = require('@bahmutov/cy-rollup')
4+
on('file:preprocessor', filePreprocessor())
45

56
// https://github.com/cypress-io/code-coverage
67
require('@cypress/code-coverage/task')(on, config)

package-lock.json

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
"watch": "tsc -w",
4343
"semantic-release": "semantic-release"
4444
},
45+
"dependencies": {
46+
"@bahmutov/cy-rollup": "2.0.0"
47+
},
4548
"devDependencies": {
46-
"@bahmutov/cy-rollup": "1.1.3",
4749
"@cypress/code-coverage": "3.7.0",
4850
"@cypress/webpack-preprocessor": "5.1.2",
4951
"@rollup/plugin-alias": "3.1.0",

0 commit comments

Comments
 (0)