Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add defineConfig function to help type config #18302

Merged
merged 8 commits into from
Oct 5, 2021
17 changes: 17 additions & 0 deletions cli/lib/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ const cypressModuleApi = {
return cli.parseRunCommand(args)
},
},

/**
* Provides automatic code completion for configuration in many popular code editors.
* While it's not strictly necessary for Cypress to parse your configuration, we
* recommend wrapping your config object with `defineConfig()`
* @example
* module.exports = defineConfig({
* viewportWith: 400
* })
*
* @see ../types/cypress-npm-api.d.ts
* @param {Cypress.ConfigOptions} config
* @returns {Cypress.ConfigOptions} the configuration passed in parameter
*/
defineConfig (config) {
return config
},
}

module.exports = cypressModuleApi
15 changes: 15 additions & 0 deletions cli/types/cypress-npm-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,21 @@ declare module 'cypress' {
* Cypress does
*/
cli: CypressCommandLine.CypressCliParser

/**
* Provides automatic code completion for configuration in many popular code editors.
* While it's not strictly necessary for Cypress to parse your configuration, we
* recommend wrapping your config object with `defineConfig()`
* @example
* module.exports = defineConfig({
* viewportWith: 400
* })
*
* @see ../types/cypress-npm-api.d.ts
* @param {Cypress.ConfigOptions} config
* @returns {Cypress.ConfigOptions} the configuration passed in parameter
*/
defineConfig(config: Cypress.ConfigOptions): Cypress.ConfigOptions
}

// export Cypress NPM module interface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = {
const { defineConfig } = require('cypress')

module.exports = defineConfig({
pageLoadTimeout: 10000,
e2e: {
defaultCommandTimeout: 500,
videoCompression: 20,
},
}
})