Skip to content

Commit

Permalink
fix: support Cypress versions before 10 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jan 24, 2023
1 parent 2c1f671 commit b33f899
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ module.exports = defineConfig({

**Important:** return the `config` object from the `setupNodeEvents` function.

### Cypress versions before v10

```js
// cypress/plugins/index.js
// https://github.com/bahmutov/cypress-split
const cypressSplit = require('cypress-split')

module.exports = (on, config) => {
cypressSplit(on, config)
// IMPORTANT: return the config object
return config
})
```

Now update your CI script:

### GitLab CI
Expand Down
10 changes: 9 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,15 @@ function cypressSplit(on, config) {
if (splitSpecs.length) {
debug('setting the spec pattern to')
debug(splitSpecs)
config.specPattern = splitSpecs
if (config.integrationFolder) {
debug('setting test files')
config.testFiles = splitSpecs.map((name) =>
path.relative(config.integrationFolder, name),
)
} else {
// Cypress v10+
config.specPattern = splitSpecs
}
} else {
// copy the empty spec file from our source folder into temp folder
const tempFilename = path.join(
Expand Down

0 comments on commit b33f899

Please sign in to comment.