diff --git a/cli/lib/cypress.js b/cli/lib/cypress.js index d87e11277c03..3ecbad4c2dd5 100644 --- a/cli/lib/cypress.js +++ b/cli/lib/cypress.js @@ -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 diff --git a/cli/types/cypress-npm-api.d.ts b/cli/types/cypress-npm-api.d.ts index 1c44e841de8f..c60a34713812 100644 --- a/cli/types/cypress-npm-api.d.ts +++ b/cli/types/cypress-npm-api.d.ts @@ -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 diff --git a/packages/server/test/support/fixtures/projects/config-with-custom-file-js/cypress.config.custom.js b/packages/server/test/support/fixtures/projects/config-with-custom-file-js/cypress.config.custom.js index d95722d5dddc..509c254dbb21 100644 --- a/packages/server/test/support/fixtures/projects/config-with-custom-file-js/cypress.config.custom.js +++ b/packages/server/test/support/fixtures/projects/config-with-custom-file-js/cypress.config.custom.js @@ -1,7 +1,9 @@ -module.exports = { +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ pageLoadTimeout: 10000, e2e: { defaultCommandTimeout: 500, videoCompression: 20, }, -} +})