I have trouble running tests on Windows with the --no-sandbox flag. Without it, it works with no issues, but if not then I get the error
Disconnected reconnect failed before timeout of x ms (transport close)
Within the docker it runs with no issues with --no-sandbox flag and without the flag it says that it's not supported or something like that.
Have you experienced such issues? How did you manage to solve them?
I checked most of the questions on stack and on the web, but it seems that nothing solves this issue.
I tried - setting additional, different flags, but none of the setups worked
I tried removing this flag - but that's needed in docker.
I tried updating all of the test libraries - nothing helps.
Here is my karma config
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
// this ensures we always have a fresh chrome copy
// and that it's usable in a ci/cd perspective
const process = require('process');
process.env.CHROME_BIN = require('puppeteer').executablePath()
module.exports = function (config) {
config.set({
debugMode: true,
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
jasmine: {
random: false
}
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/Frontend'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox']
}
},
singleRun: true,
restartOnFileChange: true,
});
};
CodePudding user response:
If possible, you can have 2 scripts.
Try making the following changes:
browsers: ['ChromeHeadlessNoSandbox', 'Chrome'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox']
}
package.json
"test": "ng test --browsers ChromeHeadlessNoSandbox",
"test:windows": "ng test --browsers Chrome"
Something like that. Basically one script for the tests in Windows and another for the Docker/CI/CD.