在docker中运行角度单位测试-无法加载浏览器RangeError:超出了最大调用堆栈大小

时间:2019-01-28 20:53:09

标签: angular docker karma-jasmine karma-chrome-launcher

我在为docker容器内的角度项目运行单元测试时遇到问题。我经历了我能想到的所有事情,但似乎找不到问题。这些测试可以在docker外部使用相同的命令正常运行。

我正在使用node.11.8.0-alpine和最新版本的铬

我收到以下错误:

  

错误[启动器]:无法加载浏览器“ ChromeHeadless”! RangeError:   超出最大呼叫堆栈大小       在String.match()       在/ng-app/node_modules/di/lib/annotation.js:30:17       在Array.map()       在解析时(/ng-app/node_modules/di/lib/annotation.js:29:42)       在Array.invoke(/ng-app/node_modules/di/lib/injector.js:69:46)       在Injector.get(/ng-app/node_modules/di/lib/injector.js:48:43)       在模块上。(匿名函数)(/ng-app/node_modules/karma/lib/config.js:249:64)       在Array.invoke(/ng-app/node_modules/di/lib/injector.js:75:15)       在Injector.get(/ng-app/node_modules/di/lib/injector.js:48:43)       在模块上。(匿名函数)(/ng-app/node_modules/karma/lib/config.js:249:64)       在Array.invoke(/ng-app/node_modules/di/lib/injector.js:75:15)       在Injector.get(/ng-app/node_modules/di/lib/injector.js:48:43)       在模块上。(匿名函数)(/ng-app/node_modules/karma/lib/config.js:249:64)       在Array.invoke(/ng-app/node_modules/di/lib/injector.js:75:15)       在Injector.get(/ng-app/node_modules/di/lib/injector.js:48:43)       在模块上。(匿名函数)(/ng-app/node_modules/karma/lib/config.js:249:64)28 01 2019   20:34:52.281:ERROR [因果服务器]:错误:找到1个加载错误       在Server.webServer.listen(/ng-app/node_modules/karma/lib/server.js:182:27)       在Object.onceWrapper(events.js:285:13)       在Server.emit(events.js:202:15)       在emitListeningNT(net.js:1290:10)       在processTicksAndRejections(internal / process / next_tick.js:76:17)处无法读取未定义TypeError的属性“成功”:无法读取   未定义的属性“成功”       在TestCommand.runSingleTarget(/ng-app/node_modules/@angular/cli/models/packages/angular/cli/models/architect-command.ts:242:21)       在processTicksAndRejections(internal / process / next_tick.js:81:5)出现分段错误

以下是我的业力配置:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-junit-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    junitReporter: {
      outputDir: '/test-reports', // results will be saved as $outputDir/$browserName.xml
      outputFile: 'junit-report.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
      suite: '', // suite will become the package name attribute in xml testsuite element
      useBrowserName: false, // add browser name to report and classes names
    },
    reporters: ['junit'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: false,
    browserNoActivityTimeout: 60000,
    browsers: ['ChromeHeadless'],
    customLaunchers: {
      ChromeHeadless: {
        base: 'ChromeHeadless',
        flags: [
          '--disable-web-security',
          '--disable-gpu',
          '--no-sandbox'
        ]
      }
    },
    singleRun: true
  });
};

版本:

"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"karma-junit-reporter": "^1.2.0",
"@angular-devkit/build-angular": "~0.12.2",
"@angular/cli": "^7.2.3",
"@angular/compiler-cli": "^7.2.2",

0 个答案:

没有答案