twolfson / karma-electron

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

2 Electron Windows open if setting the "--show" flag? #28

Closed conanak99 closed 6 years ago

conanak99 commented 6 years ago

When I tried to set the --show flag in karma.conf.js, the launcher open 2 electron windows instead of 1. (1 with Karma and 1 empty)

image

This is my karma.conf.js

    preprocessors: {
      '**/*.js': ['electron'],
      '**/*.spec.js': ['electron']
    },
    client: {
      useIframe: false
    },
    browsers: ['CustomElectron'],
    customLaunchers: {
      CustomElectron: {
        base: 'Electron',
        flags: ['--show']
      }
    }

If I remove the --show flag, the unit test is run headerless as expected.

twolfson commented 6 years ago

Sorry for the slow reply. This is the expected behavior; Karma operates on 2 contexts:

Normally Karma loads the child context in an iframe of the parent context. However, we use client.useIframe which causes Karma to load the child context as a separate window. This is required due to security issues for iframes in Electron