dceky 1.2.0 → 1.2.1-beta-setup-node-events.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -137,3 +137,13 @@ const myReturnValue = { hello: 'world' };
137
137
 
138
138
  return ky.wrap(myReturnValue);
139
139
  ```
140
+
141
+ ### Adding a Custom Setup Node Events Script
142
+
143
+ If you want to add a custom `setupNodeEvents` script, create a `/cypress/support/setupNodeEvents.ts` module that exports a single default function of the following type:
144
+
145
+ ```ts
146
+ ((on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => Cypress.PluginConfigOptions | void)
147
+ ```
148
+
149
+ Ky will automatically look for this file and add it to the configuration if it exists, so there's no need to import it or add it to the config manually. This is useful for adding custom functionality that happens _outside the browser_.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dceky",
3
- "version": "1.2.0",
3
+ "version": "1.2.1-beta-setup-node-events.1",
4
4
  "description": "Cypress toolkit for Harvard DCE",
5
5
  "main": "./lib/src/index.js",
6
6
  "types": "./lib/src/index.d.ts",
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable global-require */
3
3
  /* eslint-disable import/no-dynamic-require */
4
4
  import path from 'path';
5
+ import fs from 'fs';
5
6
 
6
7
  // Import cypress
7
8
  import { defineConfig } from 'cypress';
@@ -111,11 +112,23 @@ const genConfiguration = () => {
111
112
  baseUrl = `https://${baseUrl}`;
112
113
  }
113
114
 
115
+ // Look for a /cypress/support/setupNodeEvents.ts file and add it to the config if it exists
116
+ const setupNodeEventsPath = path.join(CWD, '/cypress/support/setupNodeEvents.ts');
117
+ const setupNodeEventsExists = fs.existsSync(setupNodeEventsPath);
118
+ let setupNodeEvents: (
119
+ ((on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => Cypress.PluginConfigOptions | void)
120
+ | undefined
121
+ );
122
+ if (setupNodeEventsExists) {
123
+ setupNodeEvents = require(setupNodeEventsPath).default;
124
+ }
125
+
114
126
  // Return the configuration object
115
127
  return defineConfig({
116
128
  e2e: {
117
129
  experimentalWebKitSupport: true,
118
130
  experimentalOriginDependencies: true,
131
+ setupNodeEvents,
119
132
  baseUrl,
120
133
  expose: exposed,
121
134
  env: securedEnv,