twolfson / karma-electron

Karma launcher and preprocessor for Electron
The Unlicense
59 stars 21 forks source link

Unable to open Electron window using --show #37

Closed trusktr closed 5 years ago

trusktr commented 5 years ago

I'm trying to use the --show option to open an Electron window to debug tests, but a window never appears.

My config is:

// ...

module.exports = function(config) {

    config.set({

        frameworks: ['jasmine', 'stacktrace'],
        reporters: ['spec'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: false,
        // singleRun: false,
        concurrency: Infinity,

        basePath: CWD,

        browsers: ['CustomElectron'],
        customLaunchers: {
            CustomElectron: {
                base: 'Electron',

                flags: [
                    '--show'
                ],
            }
        },

        files: [
            '.karma-test-build/**/*.js',
        ],
        preprocessors: {
            '.karma-test-build/**/*.js': ['electron'],
        },
        client: {
            useIframe: false,
            loadScriptsViaRequire: true,
        },

    })

}

Then I'm running

./node_modules/.bin/karma start --no-single-run --browsers Electron ./config/karma.config.js

I see the Electron icon in my macOS dock, but no window. If I change --no-single-run to --single-run, then I'll see tests successfully fly by in my terminal.

What may be missing?

trusktr commented 5 years ago

I'm using karma-electron v6.0.0

twolfson commented 5 years ago

You're specifying --browsers Electron in the CLI execution. This is overriding the browsers: ['CustomElectron'] in the configuration. This can be fixed by either:

trusktr commented 5 years ago

Oh goodness, sorry for wasting your time. That was my problem all along!

I've removed the CLI flag, and --show works now, and I've also verified that when using '--remote-debugging-port=9222' I can also inspect from the Chrome browser using chrome://inspect.

Thanks!