Skip to content

Commit

Permalink
feat: add ts file with types (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov authored Oct 10, 2023
1 parent 203648a commit afcd431
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,28 @@ module.exports = defineConfig({
})
```

## TypeScript

Types are in [src/types.d.ts](./src/types.d.ts) file. You should be able to import the config function in your TS config file.

```ts
import { defineConfig } from 'cypress'
import cypressSplit from 'cypress-split'

module.exports = defineConfig({
e2e: {
// baseUrl, etc
supportFile: false,
fixturesFolder: false,
setupNodeEvents(on, config) {
cypressSplit(on, config)
// IMPORTANT: return the config object
return config
},
},
})
```

### Multiple plugins

If you are using many Cypress plugins (for example my plugins covered in the [Cypress Plugins](https://cypress.tips/courses/cypress-plugins) course), you might notice that only the last plugin really works. This is due to a bug, and you can work around it using [cypress-on-fix](https://github.com/bahmutov/cypress-on-fix).
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"files": [
"src"
],
"types": "src/types.d.ts",
"scripts": {
"test": "cypress run",
"badges": "npx -p dependency-version-badge update-badge cypress",
Expand Down
10 changes: 10 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type Cypress from 'cypress'

/**
* Initializes the cypress-split plugin using Cypress config values.
* @see https://github.com/bahmutov/cypress-split
*/
export default function cypressSplit(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions,
): void

0 comments on commit afcd431

Please sign in to comment.