Skip to content

Commit cb5b547

Browse files
authored
fix: Long Cypress verification times (#21174)
* Fixing some electron * More electron refs * Updating system test snapshots. Updating mocha timeout for module-api tests. * Updating magic require with comment * Updating system test snapshot again * Removing dead code
1 parent 8f7a50f commit cb5b547

File tree

6 files changed

+18
-20
lines changed

6 files changed

+18
-20
lines changed

packages/server/lib/cypress.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
require('./environment')
22

3+
// We require project-base here, as waiting to require it in
4+
// the Electron process for the first time can cause the process
5+
// to hang during smoke test execution. This occurs with Electron
6+
// version v15.4.0 and after.
7+
//
8+
// TODO: Investigate need/removal of this with future major versions
9+
// of Electron when upgraded: https://github.com/cypress-io/cypress/pull/19090
10+
require('@packages/server/lib/project-base')
11+
312
// we are not requiring everything up front
413
// to optimize how quickly electron boots while
514
// in dev or linux production. the reasoning is
@@ -114,12 +123,6 @@ module.exports = {
114123
})
115124
},
116125

117-
openProject (options) {
118-
// this code actually starts a project
119-
// and is spawned from nodemon
120-
require('../lib/open_project').open(options.project, options)
121-
},
122-
123126
start (argv = []) {
124127
debug('starting cypress with argv %o', argv)
125128

packages/server/lib/gui/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const express = require('express')
44
const os = require('os')
55
const pkg = require('@packages/root')
66
const Promise = require('bluebird')
7-
const { shell } = require('electron')
87
const url = require('url')
98

109
const machineId = require('../util/machine_id')
@@ -164,7 +163,7 @@ const launchNativeAuth = Promise.method((loginUrl, sendMessage) => {
164163

165164
openExternalAttempted = true
166165

167-
return shell.openExternal(loginUrl)
166+
return require('electron').shell.openExternal(loginUrl)
168167
.catch((err) => {
169168
debug('Error launching native auth: %o', { err })
170169
warnCouldNotLaunch()

packages/server/lib/gui/links.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import _ from 'lodash'
2-
import { shell } from 'electron'
32
import { URL, URLSearchParams } from 'url'
43

54
// NOTE: in order for query params to be passed through on links
@@ -12,7 +11,7 @@ interface OpenExternalOptions {
1211

1312
export const openExternal = (opts: OpenExternalOptions | string) => {
1413
if (_.isString(opts)) {
15-
return shell.openExternal(opts)
14+
return require('electron').shell.openExternal(opts)
1615
}
1716

1817
const url = new URL(opts.url)
@@ -26,5 +25,5 @@ export const openExternal = (opts: OpenExternalOptions | string) => {
2625
url.search = new URLSearchParams(opts.params).toString()
2726
}
2827

29-
return shell.openExternal(url.href)
28+
return require('electron').shell.openExternal(url.href)
3029
}

packages/server/lib/makeDataContext.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DataContext, getCtx, clearCtx, setCtx } from '@packages/data-context'
2-
import electron, { OpenDialogOptions, SaveDialogOptions, BrowserWindow } from 'electron'
2+
import type { OpenDialogOptions, SaveDialogOptions, BrowserWindow } from 'electron'
33
import pkg from '@packages/root'
44
import * as configUtils from '@packages/config'
55
import { isListening } from './util/ensure-url'
@@ -160,16 +160,16 @@ export function makeDataContext (options: MakeDataContextOptions): DataContext {
160160
})
161161
},
162162
showItemInFolder (folder: string) {
163-
electron.shell.showItemInFolder(folder)
163+
require('electron').shell.showItemInFolder(folder)
164164
},
165165
showOpenDialog (props: OpenDialogOptions) {
166-
return electron.dialog.showOpenDialog(props)
166+
return require('electron').dialog.showOpenDialog(props)
167167
},
168168
showSaveDialog (window: BrowserWindow, props: SaveDialogOptions) {
169-
return electron.dialog.showSaveDialog(window, props)
169+
return require('electron').dialog.showSaveDialog(window, props)
170170
},
171171
copyTextToClipboard (text: string) {
172-
electron.clipboard.writeText(text)
172+
require('electron').clipboard.writeText(text)
173173
},
174174
},
175175
localSettingsApi: {

system-tests/__snapshots__/reporters_spec.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ Error: Cannot find module '/foo/bar/.projects/e2e/node_modules/module-does-not-e
1212
Require stack:
1313
- lib/reporter.js
1414
- lib/project-base.ts
15-
- lib/open_project.ts
16-
- lib/makeDataContext.ts
17-
- lib/modes/index.ts
1815
- lib/cypress.js
1916
- index.js
2017
-

system-tests/projects/module-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"private": true,
66
"main": "index.js",
77
"scripts": {
8-
"test": "mocha --timeout 30000 test/spec.js"
8+
"test": "mocha --timeout 45000 test/spec.js"
99
},
1010
"devDependencies": {
1111
"@bahmutov/all-paths": "1.0.2",

0 commit comments

Comments
 (0)