I have an angular (5) project running jasmine unit-tests using karma & chrome headless. This works fine locally but fails on our VSTS CI server (Custom Windows 10 VM with node & chrome [69] installed).
The build-agent installed on the VSTS VM runs as a windows service, which fails the chrome headless tests with a timeout:
2018-10-03T12:28:51.8716712Z [32m03 10 2018 12:28:04.336:INFO [karma]: [39mKarma v1.7.1 server started at http://0.0.0.0:9876/
2018-10-03T12:28:51.8717001Z [32m03 10 2018 12:28:04.336:INFO [launcher]: [39mLaunching browser ChromeHeadless with unlimited concurrency
2018-10-03T12:28:51.8717325Z [32m03 10 2018 12:28:04.351:INFO [launcher]: [39mStarting browser Chrome
2018-10-03T12:28:51.8717666Z [32m03 10 2018 12:28:40.937:INFO [HeadlessChrome 69.0.3497 (Windows 10.0.0)]: [39mConnected on socket vcUeG8L1qWsAFV7LAAAA with id 91653372
2018-10-03T12:28:51.8717989Z [33m03 10 2018 12:28:50.945:WARN [HeadlessChrome 69.0.3497 (Windows 10.0.0)]: [39mDisconnected (1 times), because no message in 10000 ms.
2018-10-03T12:28:51.8718289Z [31mHeadlessChrome 69.0.3497 (Windows 10.0.0) ERROR[39m
2018-10-03T12:28:51.8718600Z Disconnected, because no message in 10000 ms.
2018-10-03T12:28:51.8718863Z
2018-10-03T12:28:51.8719156Z HeadlessChrome 69.0.3497 (Windows 10.0.0) ERROR
2018-10-03T12:28:51.8719433Z Disconnected, because no message in 10000 ms.
2018-10-03T12:28:51.8719704Z HeadlessChrome 69.0.3497 (Windows 10.0.0) ERROR
2018-10-03T12:28:51.8720051Z Disconnected, because no message in 10000 ms.
If I change the build-agent to run in interactive mode the tests start working again. But this is a not ideal situation as in interactive mode we need to restart the build-agent manually when the server reboots.
Tests are run using:
ng test --code-coverage --browsers ChromeHeadless --single-run
karma.conf.js has custom launcher flags enabled:
--headless
--disable-gpu
--remote-debugging-port=9222