Karma tests on Edge and azure pipelines

5.1k Views Asked by At

When trying to run my karma test suit on Edge, in Azure pipelines, I have the following error:

18 05 2020 16:34:20.217:INFO [karma-server]: Karma v5.0.7 server started at http://0.0.0.0:9876/
18 05 2020 16:34:20.217:INFO [launcher]: Launching browsers Edge with concurrency unlimited
18 05 2020 16:34:20.312:INFO [launcher]: Starting browser Edge
18 05 2020 16:34:46.536:ERROR [launcher]: Killing Edge process failed. Error: Command failed: taskkill /t /f /im MicrosoftEdge.exe
ERROR: The process "MicrosoftEdge.exe" not found.

18 05 2020 16:34:46.536:ERROR [launcher]: Cannot start Edge
    undefined
18 05 2020 16:34:46.536:ERROR [launcher]: Edge stdout: 
Couldn't find Edge URL with URL: 00D53958
Found
18 05 2020 16:34:46.536:ERROR [launcher]: Edge stderr: 
18 05 2020 16:34:46.536:INFO [launcher]: Trying to start Edge again (1/2).
18 05 2020 16:35:07.958:ERROR [launcher]: Killing Edge process failed. Error: Command failed: taskkill /t /f /im MicrosoftEdge.exe
ERROR: The process "MicrosoftEdge.exe" not found.

18 05 2020 16:35:07.958:ERROR [launcher]: Cannot start Edge
    undefined
18 05 2020 16:35:07.958:ERROR [launcher]: Edge stdout: 
Couldn't find Edge URL with URL: 00100250
Found
18 05 2020 16:35:07.958:ERROR [launcher]: Edge stderr: 
18 05 2020 16:35:07.973:INFO [launcher]: Trying to start Edge again (2/2).
18 05 2020 16:35:29.343:ERROR [launcher]: Killing Edge process failed. Error: Command failed: taskkill /t /f /im MicrosoftEdge.exe
ERROR: The process "MicrosoftEdge.exe" not found.

18 05 2020 16:35:29.343:ERROR [launcher]: Cannot start Edge
    undefined
18 05 2020 16:35:29.343:ERROR [launcher]: Edge stdout: 
Couldn't find Edge URL with URL: 013BFFB0
Found
18 05 2020 16:35:29.343:ERROR [launcher]: Edge stderr: 
18 05 2020 16:35:29.359:ERROR [launcher]: Edge failed 2 times (cannot start). Giving up.

It is running in a microsoft hosted windows-2019 VM, according to the documentation, it should be configured correctly. Has anyone ever made this setup work?

For the record, Internet Explorer works fine the same setup!

2

There are 2 best solutions below

2
Jeremad On BEST ANSWER

I managed to make that work with a custom plugin: https://github.com/karma-runner/karma-edge-launcher

You can then use the Edge browser.

1
Dcode22 On

A simple workaround if integrating with edge fails: even if you do not have Chrome installed, you can set the default browser to ChromeHeadless in the the karma.conf.js by changing the 'browsers' setting to 'ChromeHeadless' as follows:

browsers: ['ChromeHeadless'],

then once you are running the tests you can open http://localhost:9876/ in Microsoft Edge and it will show the regular karma testing window.

Alternatively, without setting the default browser, you can also do the same by using the command ng test --browsers ChromeHeadless