From afcd431e503bb7a58ee5dcec8ee2d4b5d62490c9 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Tue, 10 Oct 2023 15:21:54 -0400 Subject: [PATCH] feat: add ts file with types (#110) --- README.md | 22 ++++++++++++++++++++++ package.json | 1 + src/types.d.ts | 10 ++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/types.d.ts diff --git a/README.md b/README.md index d8eb7a1..50dbec3 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/package.json b/package.json index 62cae2a..4a3a13f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "files": [ "src" ], + "types": "src/types.d.ts", "scripts": { "test": "cypress run", "badges": "npx -p dependency-version-badge update-badge cypress", diff --git a/src/types.d.ts b/src/types.d.ts new file mode 100644 index 0000000..0b062a5 --- /dev/null +++ b/src/types.d.ts @@ -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