mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 23:49:43 -05:00
fix: UNIFY-676 browsers should be configurable in setupNodeEvents (#20367)
* fix: Add test for UNIFY-676
* Update packages/types/src/browser.ts
* fixes to types, failing test
* chore: fix typing errors
* Revert "chore: fix typing errors"
This reverts commit 97ba5cf496.
* fix: for browsers field, fix types
Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
This commit is contained in:
Vendored
+22
-16
@@ -198,7 +198,7 @@ declare namespace Cypress {
|
||||
/**
|
||||
* The configuration for Cypress.
|
||||
*/
|
||||
type Config = ResolvedConfigOptions & RuntimeConfigOptions
|
||||
type Config = ResolvedConfigOptions & RuntimeConfigOptions & RuntimeServerConfigOptions
|
||||
|
||||
/**
|
||||
* Several libraries are bundled with Cypress by default.
|
||||
@@ -2898,7 +2898,7 @@ declare namespace Cypress {
|
||||
*/
|
||||
clientCertificates: ClientCertificate[]
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handle Cypress plugins
|
||||
*/
|
||||
setupNodeEvents: (on: PluginEvents, config: PluginConfigOptions) => Promise<PluginConfigOptions> | PluginConfigOptions
|
||||
@@ -2907,17 +2907,17 @@ declare namespace Cypress {
|
||||
/**
|
||||
* Options appended to config object on runtime.
|
||||
*/
|
||||
interface RuntimeConfigOptions {
|
||||
interface RuntimeConfigOptions extends Partial<RuntimeServerConfigOptions> {
|
||||
/**
|
||||
* Absolute path to the config file (default: <projectRoot>/cypress.config.{ts|js}) or false
|
||||
*/
|
||||
configFile: string | false
|
||||
/**
|
||||
* CPU architecture, from Node `os.arch()`
|
||||
*
|
||||
* @see https://nodejs.org/api/os.html#os_os_arch
|
||||
*/
|
||||
arch: string
|
||||
/**
|
||||
* The browser Cypress is running on.
|
||||
*/
|
||||
browser: Browser
|
||||
/**
|
||||
* Available browsers found on your system.
|
||||
*/
|
||||
@@ -2946,21 +2946,31 @@ declare namespace Cypress {
|
||||
*/
|
||||
version: string
|
||||
|
||||
// Internal or Unlisted at server/lib/config_options
|
||||
namespace: string
|
||||
projectRoot: string
|
||||
devServerPublicPathRoute: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional options added before the server starts
|
||||
*/
|
||||
interface RuntimeServerConfigOptions {
|
||||
/**
|
||||
* The browser Cypress is running on.
|
||||
*/
|
||||
browser: Browser
|
||||
// Internal or Unlisted at server/lib/config_options
|
||||
autoOpen: boolean
|
||||
browserUrl: string
|
||||
clientRoute: string
|
||||
configFile: string
|
||||
cypressEnv: string
|
||||
devServerPublicPathRoute: string
|
||||
isNewProject: boolean
|
||||
isTextTerminal: boolean
|
||||
morgan: boolean
|
||||
namespace: string
|
||||
parentTestsFolder: string
|
||||
parentTestsFolderDisplay: string
|
||||
projectName: string
|
||||
projectRoot: string
|
||||
proxyUrl: string
|
||||
remote: RemoteState
|
||||
report: boolean
|
||||
@@ -2997,11 +3007,7 @@ declare namespace Cypress {
|
||||
*/
|
||||
type ConfigOptions<ComponentDevServerOpts = any> = Partial<ResolvedConfigOptions<ComponentDevServerOpts>>
|
||||
|
||||
interface PluginConfigOptions extends ResolvedConfigOptions {
|
||||
/**
|
||||
* Absolute path to the config file (default: <projectRoot>/cypress.config.{ts|js}) or false
|
||||
*/
|
||||
configFile: string | false
|
||||
interface PluginConfigOptions extends ResolvedConfigOptions, RuntimeConfigOptions {
|
||||
/**
|
||||
* Absolute path to the root of the project
|
||||
*/
|
||||
|
||||
@@ -6,15 +6,16 @@ const pluginConfig: Cypress.PluginConfig = (on, config) => {}
|
||||
// allows synchronous returns
|
||||
const pluginConfig2: Cypress.PluginConfig = (on, config) => {
|
||||
config // $ExpectType PluginConfigOptions
|
||||
config.baseUrl // $ExpectType: string
|
||||
config.configFile // $ExpectType: string | false
|
||||
config.fixturesFolder // $ExpectType: string | false
|
||||
config.pluginsFile // $ExpectType: string | false
|
||||
config.screenshotsFolder // $ExpectType: string | false
|
||||
config.videoCompression // $ExpectType: number | false
|
||||
config.projectRoot // $ExpectType: string
|
||||
config.version // $ExpectType: string
|
||||
config.testingType // $ExpectType: TestingType
|
||||
config.baseUrl // $ExpectType string | null
|
||||
config.configFile // $ExpectType string | false
|
||||
config.fixturesFolder // $ExpectType string | false
|
||||
config.pluginsFile // $ExpectType string | false
|
||||
config.screenshotsFolder // $ExpectType string | false
|
||||
config.videoCompression // $ExpectType number | false
|
||||
config.projectRoot // $ExpectType string
|
||||
config.version // $ExpectType string
|
||||
config.testingType // $ExpectType TestingType
|
||||
config.browsers // $ExpectType Browser[]
|
||||
|
||||
on('before:browser:launch', (browser, options) => {
|
||||
browser.displayName // $ExpectType string
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
describe('config-spec', () => {
|
||||
it('can filter browsers from config', () => {
|
||||
cy.scaffoldProject('plugin-filter-browsers')
|
||||
cy.findBrowsers()
|
||||
cy.openProject('plugin-filter-browsers', ['--e2e'])
|
||||
cy.withCtx(async (ctx) => {
|
||||
expect(await ctx.browser.machineBrowsers()).to.have.length(12) // stubbed list of all browsers
|
||||
})
|
||||
|
||||
cy.visitLaunchpad()
|
||||
// Filtered down to the electron browser in the plugin
|
||||
cy.get('[data-cy="open-browser-list"]').children().should('have.length', 1)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user