Skip to content

Commit a64c809

Browse files
Alexandre Lachezecodebytere
authored andcommitted
Upgrade to support electron 4 (2) (electron-userland#361)
* chore: bump package version * chore: bump associated Electron version * chore: upgrade to electron-chromedriver 4.0.0 * chore: add new version to matrix * chore: update chai and chai-as-promised * Use random port Implement workaround found https://bitbucket.org/chromiumembedded/cef/issues/2476/cef-webdriver-instructions-will-need-to * Minor fixes of tests * Lock * 👕 * Make multi-window tests independant of the order of windowhandles() * Update to latest electron version * Do not set random if it was already set by user * Make comment clearer * Make comment more accurate
1 parent f741ee1 commit a64c809

File tree

6 files changed

+151
-120
lines changed

6 files changed

+151
-120
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ For given versions of Electron you must depend on a very specific version range
3131
| `~1.8.0` | `~3.8.0` |
3232
| `^2.0.0` | `^4.0.0` |
3333
| `^3.0.0` | `^5.0.0` |
34+
| `^4.0.0` | `^6.0.0` |
3435

3536
Learn more from [this presentation](https://speakerdeck.com/kevinsawicki/testing-your-electron-apps-with-chromedriver).
3637

lib/application.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ Application.prototype.createClient = function () {
153153
args.push(arg)
154154
})
155155

156+
// Since ChromeDriver v2.41, ChromeDriver will only connect
157+
// if, either we precise a port for remote debugging, either
158+
// the embedder (ie electron) made sure to pass `USER_DATA_DIR`
159+
// to the remote debugging server.
160+
// https://bitbucket.org/chromiumembedded/cef/issues/2476/cef-webdriver-instructions-will-need-to
161+
// `USER_DATA_DIR` is properly passed to the remote debugging server
162+
// since electron 5 (see electron/electron#17800)
163+
// So, for now, we'll just use a random port if not already set.
164+
// todo(electron-5): remove me
165+
if (!args.some(arg => arg.startsWith('remote-debugging-port'))) {
166+
const randomPort = Math.floor(Math.random() * (9999 - 9000) + 9000)
167+
args.push(`remote-debugging-port=${randomPort}`)
168+
}
169+
156170
var isWin = process.platform === 'win32'
157171
var launcherPath = path.join(__dirname, isWin ? 'launcher.bat' : 'launcher.js')
158172

package-lock.json

Lines changed: 102 additions & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spectron",
3-
"version": "5.0.0",
3+
"version": "6.0.0",
44
"description": "Easily test your Electron apps using ChromeDriver and WebdriverIO.",
55
"main": "index.js",
66
"types": "./lib/spectron.d.ts",
@@ -9,7 +9,6 @@
99
"prepack": "check-for-leaks",
1010
"prepush": "check-for-leaks",
1111
"pretest": "tslint lib/spectron.d.ts && tsc lib/spectron.d.ts",
12-
"lint": "standard",
1312
"test": "mocha && standard"
1413
},
1514
"engines": {
@@ -26,18 +25,18 @@
2625
"license": "MIT",
2726
"dependencies": {
2827
"dev-null": "^0.1.1",
29-
"electron-chromedriver": "~3.0.0",
28+
"electron-chromedriver": "~4.0.0",
3029
"request": "^2.87.0",
3130
"split": "^1.0.0",
3231
"webdriverio": "^4.13.0"
3332
},
3433
"devDependencies": {
3534
"@types/webdriverio": "^4.8.0",
36-
"chai": "^3.5.0",
37-
"chai-as-promised": "^6.0.0",
35+
"chai": "^4.2.0",
36+
"chai-as-promised": "^7.1.1",
3837
"chai-roughly": "^1.0.0",
3938
"check-for-leaks": "^1.0.2",
40-
"electron": "~3.0.0",
39+
"electron": "^4.2.2",
4140
"husky": "^0.14.3",
4241
"mocha": "^5.2.0",
4342
"standard": "^12.0.1",

test/application-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe('application loading', function () {
137137
it('gets the render process console logs and clears them', function () {
138138
return app.client.waitUntilWindowLoaded()
139139
.getRenderProcessLogs().then(function (logs) {
140-
expect(logs.length).to.equal(3)
140+
expect(logs.length).to.equal(4)
141141

142142
expect(logs[0].message).to.contain('6:14 "render log"')
143143
expect(logs[0].source).to.equal('console-api')

0 commit comments

Comments
 (0)