Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
6b0a30c
feat: ability to specify the default running browser in cypress config
alexsch01 Jun 27, 2023
6335c53
variable name changes
alexsch01 Jun 27, 2023
8861eae
oops
alexsch01 Jun 27, 2023
8f1c3bc
prevent error when config doesn't exist
alexsch01 Jun 27, 2023
de2fb5f
fixed now
alexsch01 Jun 27, 2023
8770861
getting the cypress.config.js properly
alexsch01 Jun 27, 2023
2f5f10b
browser -> defaultBrowser
alexsch01 Jun 27, 2023
e1e72c1
add defaultBrowser type
alexsch01 Jun 27, 2023
ff75d39
remove not needed parts
alexsch01 Jun 28, 2023
b61f43a
fix for cypress.config.ts
alexsch01 Jun 28, 2023
ef745da
Update cli.js
alexsch01 Jun 28, 2023
1f04fbe
Merge branch 'develop' into default-browser-config
alexsch01 Jun 28, 2023
d91a9f4
Add systemtest: default-browser-config
alexsch01 Jun 29, 2023
0e433fe
temporary changelog
alexsch01 Jun 29, 2023
dd8f70c
Update CHANGELOG.md
alexsch01 Jun 29, 2023
0c502df
Update CHANGELOG.md
alexsch01 Jun 29, 2023
2f333b1
Merge branch 'cypress-io:develop' into default-browser-config
alexsch01 Jun 29, 2023
8cc35f5
Update cli.js
alexsch01 Jun 30, 2023
531c918
fix "-b" override
alexsch01 Jun 30, 2023
6de2752
method won't work for typescript config
alexsch01 Jun 30, 2023
e60534f
"defaultBrowser" -> "browser"
alexsch01 Jul 7, 2023
d013371
Revert CLI changes
alexsch01 Jul 11, 2023
a2c2b83
LETS GO
alexsch01 Jul 11, 2023
8426e3f
Update ProjectLifecycleManager.ts
alexsch01 Jul 11, 2023
90c8da2
isRunMode instead of going through config
alexsch01 Jul 11, 2023
6253f77
oops
alexsch01 Jul 11, 2023
f7524f3
Merge branch 'develop' into default-browser-config
lmiller1990 Jul 12, 2023
66b284d
remove browser RuntimeServerConfigOptions option
alexsch01 Jul 12, 2023
a8a8223
Make logic more clear
alexsch01 Jul 12, 2023
6688398
Update CHANGELOG.md
alexsch01 Jul 12, 2023
9e9a161
Update CHANGELOG.md
alexsch01 Jul 12, 2023
5a95d87
move browsers variable since unused above
alexsch01 Jul 14, 2023
13856b6
Update ProjectLifecycleManager.ts
alexsch01 Jul 14, 2023
6d57b65
add isBrowserGivenByCLI mode option
alexsch01 Jul 14, 2023
2736c5e
fix cypress open error for specific browserLaunch edge case
alexsch01 Jul 17, 2023
9823713
Update ProjectLifecycleManager.ts
alexsch01 Jul 17, 2023
c423b84
Back to default browser (#4)
alexsch01 Jul 18, 2023
3e47dae
Add to packages/config/src/options.ts
alexsch01 Jul 18, 2023
75ff26f
use browser instead of defaultBrowser
lmiller1990 Jul 20, 2023
97f4672
update tests
lmiller1990 Jul 20, 2023
f317b1c
merge develop
lmiller1990 Jul 20, 2023
996a728
Update ProjectLifecycleManager.ts
alexsch01 Jul 27, 2023
83ad754
Update index.ts
alexsch01 Jul 27, 2023
23c9c71
Update spec.cy.js
alexsch01 Jul 27, 2023
3c754c8
make alphabetical
alexsch01 Jul 27, 2023
bc3da51
Revert workaround 1
alexsch01 Jul 28, 2023
20d68e7
Revert workaround 2
alexsch01 Jul 29, 2023
475b51a
Remove browser config option for packages/config/src/options.ts
alexsch01 Jul 29, 2023
d51e789
Merge branch 'develop' into default-browser-config
jordanpowell88 Aug 2, 2023
938c4e6
refactor and add validation
lmiller1990 Aug 8, 2023
9be9ce4
merge in dev
lmiller1990 Aug 8, 2023
60193aa
fix ts build
alexsch01 Aug 8, 2023
817cc09
Update ProjectLifecycleManager.ts
alexsch01 Aug 9, 2023
7e021a6
Update coreDataShape.ts
alexsch01 Aug 9, 2023
442e41c
Update index.ts
alexsch01 Aug 9, 2023
12fc076
Update modeOptions.ts
alexsch01 Aug 9, 2023
72f590a
Merge branch 'develop' into default-browser-config
jennifer-shehane Aug 15, 2023
137fadf
fix ts
lmiller1990 Aug 16, 2023
7a77867
remove unused test project
lmiller1990 Aug 16, 2023
20fc144
fix tests
lmiller1990 Aug 16, 2023
9cba663
update test
lmiller1990 Aug 17, 2023
d7cb149
fix test
lmiller1990 Aug 17, 2023
850848c
tests
lmiller1990 Aug 17, 2023
76e194d
fix ts
alexsch01 Aug 18, 2023
da35999
Merge branch 'develop' into default-browser-config
lmiller1990 Aug 18, 2023
fe64677
Merge branch 'develop' into default-browser-config
jennifer-shehane Aug 18, 2023
344f701
WIP fix
alexsch01 Aug 24, 2023
905b6d5
oops for WIP fix
alexsch01 Aug 24, 2023
4b354dd
more fixes to WIP
alexsch01 Aug 24, 2023
acc024e
Update BrowserActions.ts
alexsch01 Aug 24, 2023
88a6390
huh
alexsch01 Aug 24, 2023
5c6c43b
Merge branch 'develop' into default-browser-config
lmiller1990 Aug 24, 2023
8c26200
make unit-tests pass
alexsch01 Aug 24, 2023
0dfe305
remove trailing whitespace
alexsch01 Aug 25, 2023
59e620b
Merge branch 'develop' into default-browser-config
lmiller1990 Aug 28, 2023
c774f92
fix lint
lmiller1990 Aug 29, 2023
04342e8
lit
lmiller1990 Aug 29, 2023
fa8025b
tests
lmiller1990 Aug 29, 2023
b1bc084
Merge branch 'develop' into default-browser-config
alexsch01 Aug 29, 2023
a34b895
Update config.ts
alexsch01 Aug 29, 2023
e1f535d
Merge branch 'develop' into default-browser-config
alexsch01 Aug 29, 2023
00d6f7c
Merge branch 'develop' into default-browser-config
lmiller1990 Aug 30, 2023
a918d9f
Merge branch 'develop' into default-browser-config
jennifer-shehane Aug 31, 2023
16a194e
Merge branch 'develop' into default-browser-config
alexsch01 Sep 5, 2023
8607b64
reorder browser in snapshot results spec
alexsch01 Sep 11, 2023
04a758a
Merge branch 'develop' into default-browser-config
alexsch01 Sep 11, 2023
a2fa2c2
Merge branch 'develop' into default-browser-config
jennifer-shehane Sep 12, 2023
7b0b264
Merge branch 'develop' into default-browser-config
alexsch01 Sep 19, 2023
a5cb3d9
chore: go back to defaultBrowser (#6)
alexsch01 Sep 22, 2023
f5cfb22
isBrowserGivenByCli
alexsch01 Sep 22, 2023
7b6aaab
oops
alexsch01 Sep 22, 2023
c9ba172
Update index.ts
alexsch01 Sep 22, 2023
b91e7df
finally done
alexsch01 Sep 22, 2023
af58fea
Merge branch 'develop' into default-browser-config
alexsch01 Sep 22, 2023
21ad307
Update CHANGELOG.md
alexsch01 Sep 22, 2023
009515d
Update CHANGELOG.md
alexsch01 Sep 22, 2023
4e95544
Update CHANGELOG.md
alexsch01 Sep 22, 2023
ae6a729
Update CHANGELOG.md
alexsch01 Sep 22, 2023
2a57a74
Merge branch 'develop' into default-browser-config
alexsch01 Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
_Released 09/26/2023_

**Features:**

- Added ability to specify the default running browser in cypress config. Addresses [#6646](https://github.com/cypress-io/cypress/issues/6646).
- Introduces new layout for Runs page providing additional run information. Addresses [#27203](https://github.com/cypress-io/cypress/issues/27203).

**Bugfixes:**
Expand Down
5 changes: 5 additions & 0 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3180,6 +3180,11 @@ declare namespace Cypress {
setupNodeEvents: (on: PluginEvents, config: PluginConfigOptions) => Promise<PluginConfigOptions | void> | PluginConfigOptions | void

indexHtmlFile: string

/**
* Set a default browser other than electron when user doesn't pass in "--browser".
*/
defaultBrowser: string
}

interface EndToEndConfigOptions extends Omit<CoreConfigOptions, 'indexHtmlFile'> {
Expand Down
6 changes: 5 additions & 1 deletion packages/data-context/src/DataContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface GraphQLRequestInfo {
export class DataContext {
readonly graphqlRequestInfo?: GraphQLRequestInfo
private _config: Omit<DataContextConfig, 'modeOptions'>
private _modeOptions: Readonly<Partial<AllModeOptions>>
private _modeOptions: Partial<AllModeOptions>
private _coreData: CoreDataShape
readonly lifecycleManager: ProjectLifecycleManager

Expand Down Expand Up @@ -423,4 +423,8 @@ export class DataContext {
this.#awaitingEmptyRequestCount.push(resolve)
})
}

setModeOptionsBrowser (browser: string) {
this._modeOptions.browser = browser
}
}
23 changes: 21 additions & 2 deletions packages/data-context/src/data/ProjectLifecycleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,29 @@ export class ProjectLifecycleManager {
/**
* Sets the initial `activeBrowser` depending on these criteria, in order of preference:
* 1. The value of `--browser` passed via CLI.
* 2. The last browser selected in `open` mode (by name and channel) for this project.
* 3. The first browser found.
* 2. The value of `browser` in `cypress.config`
* 3. The last browser selected in `open` mode (by name and channel) for this project.
* 4. The first browser found.
*/
async setInitialActiveBrowser () {
const configBrowser = this.loadedFullConfig?.defaultBrowser

if (configBrowser && !this.ctx.coreData.isBrowserGivenByCli) {
await this.setActiveBrowserByNameOrPath(configBrowser)

if (this.ctx.isRunMode) {
this.ctx.setModeOptionsBrowser(configBrowser)

return
}

if (this.ctx.coreData.activeBrowser) {
await this.ctx.actions.project.launchProject(this.ctx.coreData.currentTestingType)
}

return
}

if (this.ctx.coreData.cliBrowser) {
await this.setActiveBrowserByNameOrPath(this.ctx.coreData.cliBrowser)

Expand Down
2 changes: 2 additions & 0 deletions packages/data-context/src/data/coreDataShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ interface CloudDataShape {

export interface CoreDataShape {
cliBrowser: string | null
isBrowserGivenByCli: boolean
cliTestingType: string | null
activeBrowser: FoundBrowser | null
machineId: Promise<string | null>
Expand Down Expand Up @@ -180,6 +181,7 @@ export function makeCoreData (modeOptions: Partial<AllModeOptions> = {}): CoreDa
return {
servers: {},
cliBrowser: modeOptions.browser ?? null,
isBrowserGivenByCli: modeOptions.isBrowserGivenByCli ?? false,
cliTestingType: modeOptions.testingType ?? null,
machineId: machineId(),
machineBrowsers: null,
Expand Down
2 changes: 2 additions & 0 deletions packages/server/lib/modes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export = (mode, options) => {
return require('./smoke_test').run(options)
}

options.isBrowserGivenByCli = options.browser !== undefined

if (mode === 'run') {
_.defaults(options, {
socketId: random.id(10),
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/modeOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface CommonModeOptions {
_?: (string | null)[] | null
invokedFromCli: boolean
isBrowserGivenByCli: boolean
userNodePath?: string
userNodeVersion?: string
configFile?: string | null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
supportFile: false,
},
defaultBrowser: 'chrome',
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
it('works', () => {
expect(1).to.eq(1)
})
11 changes: 11 additions & 0 deletions system-tests/test/config_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,15 @@ describe('e2e config', () => {
snapshot: true,
})
})

it('launches browser using config.browser', async function () {
await Fixtures.scaffoldProject('config-default-browser')

return systemTests.exec(this, {
project: 'config-default-browser',
onStdout: (stdout) => {
expect(stdout).to.include('Browser: Chrome')
},
})
})
})