Skip to content

Commit 7e4fe53

Browse files
Barthélémy Ledouxflotwig
authored andcommitted
feat: add defineConfig function to help type config (#18302)
Co-authored-by: Zach Bloomquist <github@chary.us>
1 parent 6ba724b commit 7e4fe53

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

cli/lib/cypress.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ const cypressModuleApi = {
6868
return cli.parseRunCommand(args)
6969
},
7070
},
71+
72+
/**
73+
* Provides automatic code completion for configuration in many popular code editors.
74+
* While it's not strictly necessary for Cypress to parse your configuration, we
75+
* recommend wrapping your config object with `defineConfig()`
76+
* @example
77+
* module.exports = defineConfig({
78+
* viewportWith: 400
79+
* })
80+
*
81+
* @see ../types/cypress-npm-api.d.ts
82+
* @param {Cypress.ConfigOptions} config
83+
* @returns {Cypress.ConfigOptions} the configuration passed in parameter
84+
*/
85+
defineConfig (config) {
86+
return config
87+
},
7188
}
7289

7390
module.exports = cypressModuleApi

cli/types/cypress-npm-api.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,21 @@ declare module 'cypress' {
377377
* Cypress does
378378
*/
379379
cli: CypressCommandLine.CypressCliParser
380+
381+
/**
382+
* Provides automatic code completion for configuration in many popular code editors.
383+
* While it's not strictly necessary for Cypress to parse your configuration, we
384+
* recommend wrapping your config object with `defineConfig()`
385+
* @example
386+
* module.exports = defineConfig({
387+
* viewportWith: 400
388+
* })
389+
*
390+
* @see ../types/cypress-npm-api.d.ts
391+
* @param {Cypress.ConfigOptions} config
392+
* @returns {Cypress.ConfigOptions} the configuration passed in parameter
393+
*/
394+
defineConfig(config: Cypress.ConfigOptions): Cypress.ConfigOptions
380395
}
381396

382397
// export Cypress NPM module interface
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
module.exports = {
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
24
pageLoadTimeout: 10000,
35
e2e: {
46
defaultCommandTimeout: 500,
57
videoCompression: 20,
68
},
7-
}
9+
})

0 commit comments

Comments
 (0)