Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit b48fd44

Browse files
committed
feat: split functions from support file
BREAKING CHANGE: if you want to use custom commands, you need to explicitly require the support file like this. ```js require('@cypress/skip-test/support') ``` This way you can import individual functions without adding them as custom commands.
1 parent d82df3d commit b48fd44

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ npm install -D @cypress/skip-test
1919

2020
## Example
2121

22-
You can use this module as custom Cypress commands `cy.skipOn` and `cy.onlyOn` or by importing its functions. To use custom commands, add this module to your support file `cypress/support/index.js`
22+
You can use this module as custom Cypress commands `cy.skipOn` and `cy.onlyOn` or by importing its functions. To use custom commands like `cy.skipOn`, add this module to your support file `cypress/support/index.js`
2323

2424
```js
25-
require('@cypress/skip-test')
25+
require('@cypress/skip-test/support')
2626
```
2727

2828
### `cy.skipOn`

cypress/integration/callback-spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ onlyOn('mac', () => {
1010
})
1111

1212
skipOn('mac', () => {
13+
// this test will run on every platform but Mac
1314
it('hides this test on Mac', () => {})
1415
})

cypress/support/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
// You can read more here:
1313
// https://on.cypress.io/configuration
1414
// ***********************************************************
15-
require('../..')
15+
require('../../support')

index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ const onlyOn = (name, cb) => {
135135
}
136136
}
137137

138-
Cypress.Commands.add('skipOn', skipOn)
139-
140-
Cypress.Commands.add('onlyOn', onlyOn)
141-
142138
module.exports = {
143139
skipOn,
144140
onlyOn

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"homepage": "https://github.com/cypress-io/cypress-skip-test#readme",
3030
"files": [
3131
"index.js",
32-
"index.d.ts"
32+
"index.d.ts",
33+
"support.js"
3334
]
3435
}

support.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// <reference path="./index.d.ts" />
2+
// @ts-check
3+
4+
const { skipOn, onlyOn } = require('.')
5+
6+
Cypress.Commands.add('skipOn', skipOn)
7+
8+
Cypress.Commands.add('onlyOn', onlyOn)

0 commit comments

Comments
 (0)