Chrome的Angular karma测试不会首次启动

时间:2018-04-24 07:45:09

标签: angular angular-cli karma-jasmine

我的Angular 5应用程序中有几个测试。 当我运行命令 ng test Chrome已启动,然后在没有任何消息的情况下关闭。在控制台中我可以看到

ng test
 10% building modules 1/1 modules 0 active24 04 2018 10:17:35.961:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
24 04 2018 10:17:35.967:INFO [launcher]: Launching browser ChromeNoSanbox with unlimited concurrency
24 04 2018 10:17:35.979:INFO [launcher]: Starting browser Chrome
 67% building modules 539/566 modules 27 active ...d\flow\job-row\job-row.component.scss

经过多次尝试,我的测试开始运行。我试图复制默认的karma.conf.js和tsconfig.json以及.angular-cli.json,但没有任何帮助。 如果我在karma.conf.js中启用logLevel:config.LOG_DEBUG - 我看不到任何有用的消息:

ng test
24 04 2018 10:26:20.922:DEBUG [config]: Loading config karma.conf.js
24 04 2018 10:26:20.927:DEBUG [config]: autoWatch set to false, because of singleRun
24 04 2018 10:26:20.929:DEBUG [plugin]: Loading inlined plugin (defining framework:jasmine).
24 04 2018 10:26:20.929:DEBUG [plugin]: Loading inlined plugin (defining launcher:Chrome, launcher:ChromeHeadless, launcher:ChromeCanary, launcher:ChromeCanaryHeadless, launcher:Chromium,
launcher:ChromiumHeadless, launcher:Dartium, test).
24 04 2018 10:26:20.929:DEBUG [plugin]: Loading inlined plugin (defining reporter:kjhtml).
24 04 2018 10:26:20.930:DEBUG [plugin]: Loading inlined plugin (defining reporter:coverage-istanbul).
24 04 2018 10:26:20.930:DEBUG [plugin]: Loading inlined plugin (defining framework:@angular/cli, preprocessor:@angular/cli, reporter:@angular/cli, middleware:angularCliBlocker).
24 04 2018 10:26:20.931:DEBUG [plugin]: Loading inlined plugin (defining launcher:ChromeNoSanbox, launcher:ChromeHeadless).
 10% building modules 1/1 modules 0 active24 04 2018 10:26:21.396:DEBUG [web-server]: Instantiating middleware
24 04 2018 10:26:21.398:DEBUG [reporter]: Trying to load reporter: @angular/cli
24 04 2018 10:26:21.399:DEBUG [reporter]: Trying to load color-version of reporter: @angular/cli (@angular/cli_color)
24 04 2018 10:26:21.399:DEBUG [reporter]: Couldn't load color-version.
24 04 2018 10:26:21.424:DEBUG [reporter]: Trying to load reporter: kjhtml
24 04 2018 10:26:21.425:DEBUG [reporter]: Trying to load color-version of reporter: kjhtml (kjhtml_color)
24 04 2018 10:26:21.426:DEBUG [reporter]: Couldn't load color-version.
24 04 2018 10:26:34.636:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
24 04 2018 10:26:34.638:INFO [launcher]: Launching browser ChromeNoSanbox with unlimited concurrency
24 04 2018 10:26:34.648:INFO [launcher]: Starting browser Chrome
24 04 2018 10:26:34.650:DEBUG [temp-dir]: Creating temp dir at D:\TEMP\Windows\karma-27332409
24 04 2018 10:26:34.651:DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=D:\TEMP\Windows\karma-27332409 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications --no-sandbox http://localhost:9876/?id=27332409
 67% building modules 540/566 modules 26 active ...d\flow\job-row\job-row.component.scss

我的karma.conf.js是:

   module.exports = function (config) {
      config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular/cli'],
        plugins: [
          require('karma-jasmine'),
          require('karma-chrome-launcher'),
          require('karma-jasmine-html-reporter'),
          require('karma-coverage-istanbul-reporter'),
          require('@angular/cli/plugins/karma')
        ],
        client: {
          clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        coverageIstanbulReporter: {
          reports: ['html', 'lcovonly'],
          fixWebpackSourcePaths: true
        },
        angularCli: {
          environment: 'dev',
          sourcemaps: false
        },
        reporters: ['progress', 'kjhtml'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_DEBUG,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: true
      });
    };

0 个答案:

没有答案