electron-userland / spectron

DEPRECATED: 🔎 Test Electron apps using ChromeDriver
http://electronjs.org/spectron
MIT License
1.68k stars 229 forks source link

passing js flags #224

Closed tansaku closed 7 years ago

tansaku commented 7 years ago

I've got spectron running and I'm trying to pass in the js-flag --harmony:

    this.app = new Application({
                path: electronPath,
                args: ["--js-flags='--harmony'", appPath, testFile],
                webdriverLogPath: './webdriverlogs',
                chromeDriverLogPath: './chromedriver.log',
                chromeDriverArgs: ["--js-flags='--harmony'", '--harmony']
    });

I can see from the logs that it seems to be passed in correctly, but for some reason I get errors in the app that correspond to those that I get when I leave off the harmony flag when I run it directly.

I've even tried hard-coding electron binary to take the harmony flag:

#!/usr/bin/env node

var electron = require('./')

var proc = require('child_process')
console.log('starting election')
console.log(process.argv)
console.log(process.argv.slice(2))
var child = proc.spawn(electron, [ "--js-flags='--harmony'", '.', '../test/test.txt' ], {stdio: 'inherit'})
child.on('close', function (code) {
  process.exit(code)
})

but I still get the same errors.

I wonder if I'm not understanding something about how chromedriver works. At the moment the only different I can see is that spectron is spawning a process from launcher.js that then spawns another process via the .bin/electron command.

I also note that I can't console log anything in launcher or electron when running via spectron.

I know it's a bit obscure, but any ideas much appreciated. Has anyone else had trouble passing a harmony flag to chromedriver/spectron?

tansaku commented 7 years ago

I've fixed this - it appears that the extra single quotes that did not cause a problem for command line starts, are not liked by the spectron set up.

I got things working using the following:

    this.app = new Application({
                path: electronPath,
                args: ["--js-flags=--harmony", appPath, testFile],
                webdriverLogPath: './webdriverlogs',
                chromeDriverLogPath: './chromedriver.log'
    });