diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index 2927c73f6a6f..a0813ee54b80 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -2963,7 +2963,7 @@ declare namespace Cypress { xhrUrl: string } - interface TestConfigOverrides extends Partial> { + interface TestConfigOverrides extends Partial> { browser?: IsBrowserMatcher | IsBrowserMatcher[] keystrokeDelay?: number } @@ -2974,16 +2974,21 @@ declare namespace Cypress { type CoreConfigOptions = Partial> type DevServerFn = (cypressDevServerConfig: DevServerConfig, devServerConfig: ComponentDevServerOpts) => ResolvedDevServerConfig | Promise - interface ComponentConfigOptions extends CoreConfigOptions { + interface ComponentConfigOptions extends Omit { devServer: DevServerFn devServerConfig?: ComponentDevServerOpts } + /** + * Config options that can be assigned on cypress.config.{ts|js} file + */ + type UserConfigOptions = Omit, 'baseUrl' | 'excludeSpecPattern' | 'supportFile' | 'specPattern'> + /** * Takes ComponentDevServerOpts to track the signature of the devServerConfig for the provided `devServer`, * so we have proper completion for `devServerConfig` */ - type ConfigOptions = Partial> + type ConfigOptions = Partial> interface PluginConfigOptions extends ResolvedConfigOptions, RuntimeConfigOptions { /** diff --git a/cli/types/tests/cypress-npm-api-test.ts b/cli/types/tests/cypress-npm-api-test.ts index 776a54aeb56f..d7979e17a39a 100644 --- a/cli/types/tests/cypress-npm-api-test.ts +++ b/cli/types/tests/cypress-npm-api-test.ts @@ -32,7 +32,9 @@ cypress.run({ // provide only some config options const runConfig: Cypress.ConfigOptions = { - baseUrl: 'http://localhost:8080', + e2e: { + baseUrl: 'http://localhost:8080', + }, env: { login: false }, diff --git a/cli/types/tests/cypress-tests.ts b/cli/types/tests/cypress-tests.ts index ca80e00d71a4..52f4bef5ca7d 100644 --- a/cli/types/tests/cypress-tests.ts +++ b/cli/types/tests/cypress-tests.ts @@ -33,9 +33,10 @@ namespace CypressConfigTests { Cypress.config().baseUrl // $ExpectType string | null // setters - Cypress.config('baseUrl', '.') // $ExpectType void - Cypress.config('baseUrl', null) // $ExpectType void - Cypress.config({ baseUrl: '.', }) // $ExpectType void + Cypress.config({ e2e: { baseUrl: '.' }}) // $ExpectType void + Cypress.config({ e2e: { baseUrl: null }}) // $ExpectType void + Cypress.config({ e2e: { baseUrl: '.', }}) // $ExpectType void + Cypress.config({ component: { baseUrl: '.', devServer: () => ({} as any) } }) // $ExpectError Cypress.config('taskTimeout') // $ExpectType number Cypress.config('includeShadowDom') // $ExpectType boolean @@ -686,7 +687,6 @@ namespace CypressTestConfigOverridesTests { // set config on a per-test basis it('test', { animationDistanceThreshold: 10, - baseUrl: 'www.foobar.com', defaultCommandTimeout: 6000, env: {}, execTimeout: 6000, @@ -747,7 +747,6 @@ namespace CypressTestConfigOverridesTests { // set config on a per-suite basis describe('suite', { browser: {family: 'firefox'}, - baseUrl: 'www.example.com', keystrokeDelay: 0 }, () => {}) @@ -755,7 +754,6 @@ namespace CypressTestConfigOverridesTests { describe('suite', { browser: {family: 'firefox'}, - baseUrl: 'www.example.com', keystrokeDelay: false // $ExpectError foo: 'foo' // $ExpectError }, () => {}) diff --git a/cli/types/tests/plugins-config.ts b/cli/types/tests/plugins-config.ts index 0a22f7e468b4..1a86a0a3d110 100644 --- a/cli/types/tests/plugins-config.ts +++ b/cli/types/tests/plugins-config.ts @@ -6,7 +6,6 @@ const pluginConfig: Cypress.PluginConfig = (on, config) => {} // allows synchronous returns const pluginConfig2: Cypress.PluginConfig = (on, config) => { config // $ExpectType PluginConfigOptions - config.baseUrl // $ExpectType string | null config.configFile // $ExpectType string | false config.fixturesFolder // $ExpectType string | false config.screenshotsFolder // $ExpectType string | false @@ -66,7 +65,9 @@ const pluginConfig2: Cypress.PluginConfig = (on, config) => { }) return { - baseUrl: 'http://localhost:3000' + e2e: { + baseUrl: 'http://localhost:3000' + } } } @@ -105,7 +106,9 @@ const pluginConfig4: Cypress.PluginConfig = (on, config) => { }) return Promise.resolve({ - baseUrl: 'http://localhost:3000' + e2e: { + baseUrl: 'http://localhost:3000' + } }) } diff --git a/npm/cypress-schematic/src/builders/cypress/index.ts b/npm/cypress-schematic/src/builders/cypress/index.ts index 9e661c0472f3..8cb7457de679 100644 --- a/npm/cypress-schematic/src/builders/cypress/index.ts +++ b/npm/cypress-schematic/src/builders/cypress/index.ts @@ -79,7 +79,7 @@ function initCypress (userOptions: CypressBuilderOptions): Observable