spectron
spectron copied to clipboard
Spectron opens multiple instances of the electron app along with the terminals on windows.
I am using spectron to test an electron app, the spectron version is ^9.0.0 and the electron version is ^7.1.0, when I run the test using mocha, it opens up multiple app instances.
I get the same issue with spectron 9.0.0 and when I used spectron 5.0.0 it worked but app.electron, app.webContents, etc.. undefined.
This issue is resolved ? Even I am also facing same issue with spectron 8.0.0
The same issue. I have tried with previous versions of electron ^4.0.0 and spectron ^6.0.0
I was getting this when I used electron-mocha to trigger spectron, I tried mocha and it works fine now.
It's a hacky way, but I don't know why electron-mocha doesn't work.
Hi, i'm using electron 7.1.9 with spectron 9.0.0 and have some undefinied and weird issues about app.electron, etc, with a multiple app instance opening.
By testing some stuff, i realize that all is working great when i comment in the main.js file the devtool :
/* win.webContents.openDevTools({ mode: 'detach' }); */
It seems like chromeDriver version not match, my Electron version is 7.1.8, spectron version is 9.0.0, but lib/application client.init() reject by session not created: This version of ChromeDriver only supports Chrome version 76
, actually 7.1.8 Electron match 78.
Hi, I am using electron version 12 and an appropriate spectron version but still when I am triggering my tests it's launching multiple instances of the application.
Has anyone found a solution or a work around for this issue?
Okay, I was having the same issue. And solved by setting remote debugging port.
chromeDriverArgs: ['remote-debugging-port=9222']:
const Application = require('spectron').Application const assert = require('assert') const electronPath = require('electron') // Require Electron from the binaries included in node_modules. const path = require('path')
describe('Application launch', function () { this.timeout(10000)
beforeEach(function () {
this.app = new Application({
// Your electron path can be any binary
// i.e for OSX an example path could be '/Applications/MyApp.app/Contents/MacOS/MyApp'
// But for the sake of the example we fetch it from our node_modules.
path: path.join(__dirname, '..', 'node_modules', '.bin', 'electron' + (process.platform === 'win32' ? '.cmd' : '')),
// Assuming you have the following directory structure
// |__ my project
// |__ ...
// |__ main.js
// |__ package.json
// |__ index.html
// |__ ...
// |__ test
// |__ spec.js <- You are here! ~ Well you should be.
// The following line tells spectron to look and use the main.js file
// and the package.json located 1 level above.
args: [path.join(__dirname, '..')],
env: {
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true,
NODE_ENV: 'test'
},
waitTimeout: 10e3,
requireName: 'electronRequire',
chromeDriverLogPath: '../chromedriverlog.txt',
chromeDriverArgs: ['remote-debugging-port=9222']
})
return this.app.start()
})
afterEach(function () {
if (this.app && this.app.isRunning()) {
return this.app.stop()
}
})
it('shows an initial window', function () {
return this.app.client.getWindowCount().then(function (count) {
assert.equal(count, 1)
// Please note that getWindowCount() will return 2 if `dev tools` are opened.
// assert.equal(count, 2)
})
})
})