angular-cli: ng test. Karma: Executed 0 of 0 ERROR (0.006 secs / 0 secs)

Tests broken after migrating from CLI 1.7.4 -> 6.x.x

Versions

Angular CLI: 6.0.5
Node: 8.11.2
OS: win32 x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.6.5 (cli-only)
@angular-devkit/build-angular   0.6.5
@angular-devkit/core            0.6.5 (cli-only)
@angular-devkit/schematics      0.6.5 (cli-only)
@angular/cli                    6.0.5
@ngtools/webpack                6.0.5
@schematics/angular             0.6.5 (cli-only)
@schematics/update              0.6.5 (cli-only)
rxjs                            6.2.0
typescript                      2.7.2
webpack                         4.8.3

package.json

"scripts": {
    "build": "npm run build:dev",
    "build:dev": "npm run clean:dist && ng build",
    "build:prod": "npm run lint && npm run clean:dist && ng build --prod",
    "clean": "npm cache verify && npm run rimraf -- node_modules doc coverage dist",
    "clean:dist": "npm run rimraf -- dist",
    "clean:install": "npm cache verify && npm install",
    "e2e": "ng e2e",
    "rimraf": "rimraf",
    "lint": "ng lint",
    "start": "node server/index.js",
    "serve": "ng serve --hmr",
    "qa": "npm run lint && npm run test",
    "test": "ng test --code-coverage=true --source-map=true --watch=false",
    "test:watch": "ng test --code-coverage=true --source-map=true",
    "watch:dev": "npm run build:dev -- --watch",
    "watch:prod": "npm run build:prod -- --watch"
  },
  "dependencies": {
    "@angular/animations": "6.0.3",
    "@angular/common": "6.0.3",
    "@angular/compiler": "6.0.3",
    "@angular/core": "6.0.3",
    "@angular/forms": "6.0.3",
    "@angular/http": "6.0.3",
    "@angular/platform-browser": "6.0.3",
    "@angular/platform-browser-dynamic": "6.0.3",
    "@angular/router": "6.0.3",
    "@angularclass/hmr": "2.1.3",
    "@ngrx/effects": "6.0.1",
    "@ngrx/store": "6.0.1",
    "@ngrx/store-devtools": "6.0.1",
    "busboy": "0.2.14",
    "core-js": "2.5.6",
    "express": "4.16.3",
    "express-session": "1.15.6",
    "file-saver": "1.3.8",
    "font-awesome": "4.7.0",
    "grant-express": "4.1.1",
    "jsonwebtoken": "8.2.1",
    "lodash": "4.17.10",
    "lodash-decorators": "5.0.0",
    "moment": "2.22.1",
    "mydatepicker": "2.6.3",
    "npm-run-script": "0.0.4",
    "numeral": "2.0.6",
    "primeng": "6.0.0-alpha.1",
    "request": "2.87.0",
    "rxjs": "6.2.0",
    "rxjs-compat": "6.2.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.5",
    "@angular/cli": "^6.0.5",
    "@angular/compiler-cli": "6.0.3",
    "@angular/language-service": "6.0.3",
    "@types/jasmine": "2.8.7",
    "@types/jasminewd2": "2.0.3",
    "@types/node": "8.9.1",
    "@types/numeral": "0.0.22",
    "angular2-template-loader": "0.6.2",
    "codelyzer": "4.3.0",
    "jasmine-core": "2.8.0",
    "jasmine-marbles": "0.3.1",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "1.7.1",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage-istanbul-reporter": "2.0.0",
    "karma-jasmine": "1.1.2",
    "karma-mocha-reporter": "2.2.5",
    "protractor": "5.3.2",
    "rimraf": "2.6.2",
    "ts-node": "5.0.1",
    "tslint": "5.10.0",
    "typescript": "2.7.2",
    "wallaby-webpack": "3.9.8"
  }

Karma.conf.js

module.exports = function (config) {
    config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular-devkit/build-angular'],

        plugins: [
            require('karma-jasmine'),
            require('karma-mocha-reporter'),
            require('karma-chrome-launcher'),
            require('karma-coverage-istanbul-reporter'),
            require('@angular-devkit/build-angular/plugins/karma')
        ],

        browserNoActivityTimeout: 20000,

        coverageIstanbulReporter: {
            dir: require('path').join(__dirname, '../coverage'),
            reports: ['html', 'clover'],
            fixWebpackSourcePaths: true,
            'report-config': {
                html: { subdir: 'html' }
            }
        },

        reporters: ['mocha', 'progress', 'coverage-istanbul'],
        colors: true,
        logLevel: config.LOG_DEBUG,
        autoWatch: true,
        browsers: ['CustomChromeHeadless'],
        singleRun: false,

        customLaunchers: {
            CustomChromeHeadless: {
                base: 'ChromeHeadless',
                flags: ['--no-sandbox']
            }
        }
    });
};

ng test output

25 05 2018 16:07:38.481:DEBUG [plugin]: Loading inlined plugin (defining framework:jasmine).
25 05 2018 16:07:38.483:DEBUG [plugin]: Loading inlined plugin (defining reporter:mocha).
25 05 2018 16:07:38.483:DEBUG [plugin]: Loading inlined plugin (defining launcher:Chrome, launcher:ChromeHeadless, launcher:ChromeCanary, launcher:ChromeCanaryHeadless, launcher:Chromium, launcher:ChromiumHeadless, launcher:Dartium, test).
25 05 2018 16:07:38.483:DEBUG [plugin]: Loading inlined plugin (defining reporter:coverage-istanbul).
25 05 2018 16:07:38.483:DEBUG [plugin]: Loading inlined plugin (defining framework:@angular-devkit/build-angular, reporter:@angular-devkit/build-angular--sourcemap-reporter, reporter:@angular-devkit/build-angular--event-reporter, middleware:@angular-devkit/build-angular--blocker, middleware:@angular-devkit/build-angular--fallback).
25 05 2018 16:07:38.491:DEBUG [plugin]: Loading inlined plugin (defining launcher:CustomChromeHeadless).
 10% building modules 1/1 modules 0 active25 05 2018 16:07:38.784:DEBUG [web-server]: Instantiating middleware
25 05 2018 16:07:38.784:DEBUG [reporter]: Trying to load reporter: @angular-devkit/build-angular--sourcemap-reporter
25 05 2018 16:07:38.792:DEBUG [reporter]: Trying to load color-version of reporter: @angular-devkit/build-angular--sourcemap-reporter (@angular-devkit/build-angular--sourcemap-reporter_color)
25 05 2018 16:07:38.794:DEBUG [reporter]: Couldn't load color-version.
25 05 2018 16:07:38.794:DEBUG [reporter]: Trying to load reporter: @angular-devkit/build-angular--event-reporter
25 05 2018 16:07:38.794:DEBUG [reporter]: Trying to load color-version of reporter: @angular-devkit/build-angular--event-reporter (@angular-devkit/build-angular--event-reporter_color)
25 05 2018 16:07:38.794:DEBUG [reporter]: Couldn't load color-version.
25 05 2018 16:07:38.794:DEBUG [reporter]: Trying to load reporter: mocha
25 05 2018 16:07:38.802:DEBUG [reporter]: Trying to load color-version of reporter: mocha (mocha_color)
25 05 2018 16:07:38.804:DEBUG [reporter]: Couldn't load color-version.
25 05 2018 16:07:38.825:DEBUG [reporter]: Trying to load reporter: coverage-istanbul
25 05 2018 16:07:38.825:DEBUG [reporter]: Trying to load color-version of reporter: coverage-istanbul (coverage-istanbul_color)
25 05 2018 16:07:38.825:DEBUG [reporter]: Couldn't load color-version.
(node:30580) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
25 05 2018 16:08:00.485:DEBUG [karma]: List of files has changed, trying to execute
25 05 2018 16:08:00.485:WARN [karma]: No captured browser, open http://localhost:9876/
25 05 2018 16:08:00.495:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
25 05 2018 16:08:00.495:INFO [launcher]: Launching browser CustomChromeHeadless with unlimited concurrency
25 05 2018 16:08:00.505:INFO [launcher]: Starting browser ChromeHeadless
25 05 2018 16:08:00.505:DEBUG [temp-dir]: Creating temp dir at C:\Users\ANDREY~1.CHA\AppData\Local\Temp\karma-46718554
25 05 2018 16:08:00.513:DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\ANDREY~1.CHA\AppData\Local\Temp\karma-46718554 --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=46718554 --headless --disable-gpu --remote-debugging-port=9222                                                             25 05 2018 16:08:33.330:DEBUG [web-server]: serving: C:\Users\andrey.chalkin\Allianz\node_modules\karma\static/client.html
25 05 2018 16:08:33.386:DEBUG [karma]: List of files has changed, trying to execute
25 05 2018 16:08:33.388:WARN [karma]: No captured browser, open http://localhost:9876/
25 05 2018 16:08:33.537:DEBUG [web-server]: serving: C:\Users\andrey.chalkin\Allianz\node_modules\karma\static/karma.js
25 05 2018 16:08:33.638:DEBUG [karma]: A browser has connected on socket aOSdGmZGd8SpT_HGAAAA
25 05 2018 16:08:33.883:INFO [HeadlessChrome 66.0.3359 (Windows 10.0.0)]: Connected on socket aOSdGmZGd8SpT_HGAAAA with id 46718554
25 05 2018 16:08:33.883:DEBUG [launcher]: ChromeHeadless (id 46718554) captured in 33.388 secs
25 05 2018 16:08:33.883:DEBUG [karma]: All browsers are ready, executing
25 05 2018 16:08:33.883:DEBUG [karma]: Captured 1 browsers

START:
25 05 2018 16:08:34.554:DEBUG [middleware:karma]: custom files C:\Users\andrey.chalkin\Allianz\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins/karma-context.html C:\Users\andrey.chalkin\Allianz\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins/karma-debug.html null
25 05 2018 16:08:34.555:DEBUG [middleware:karma]: Serving customContextFile C:\Users\andrey.chalkin\Allianz\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins/karma-context.html
25 05 2018 16:08:34.558:DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=aOSdGmZGd8SpT_HGAAAA
25 05 2018 16:08:36.302:DEBUG [web-server]: serving: C:\Users\andrey.chalkin\Allianz\node_modules\@angular-devkit\build-angular\src\angular-cli-files\plugins/karma-context.html
25 05 2018 16:08:36.895:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/runtime.js /
25 05 2018 16:08:36.895:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/runtime.js
25 05 2018 16:08:36.895:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/polyfills.js /
25 05 2018 16:08:36.895:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/polyfills.js
25 05 2018 16:08:36.911:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/@angular-devkit/build-angular/node_modules/source-map-support/browser-source-map-support.js?f894bb45358bceea281c12011b12863c67d3942c /
25 05 2018 16:08:36.911:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/@angular-devkit/build-angular/node_modules/source-map-support/browser-source-map-support.js
25 05 2018 16:08:36.911:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/karma-source-map-support/lib/client.js?fcb459e84379f1ce8e91fe200d87463f3780ca1b /
25 05 2018 16:08:36.911:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/karma-source-map-support/lib/client.js
25 05 2018 16:08:37.064:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?73bc53d3671677e6a093fc74e4f9bcde57e5f7ad /
25 05 2018 16:08:37.064:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
25 05 2018 16:08:37.127:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/@angular-devkit/build-angular/node_modules/source-map-support/browser-source-map-support.js
25 05 2018 16:08:37.127:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/karma-source-map-support/lib/client.js
25 05 2018 16:08:37.127:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
25 05 2018 16:08:37.180:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e /
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/boot.js
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Requesting /absoluteC:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/adapter.js?6cf71867f538f40db053c1775b2c56a83696375c /
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Fetching C:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/adapter.js
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/scripts.js /
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/scripts.js
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/vendor.js /
25 05 2018 16:08:37.196:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/vendor.js
25 05 2018 16:08:37.338:DEBUG [web-server]: serving: C:\Users\andrey.chalkin\Allianz\node_modules\karma\static/context.js
25 05 2018 16:08:37.342:DEBUG [middleware:source-files]: Requesting /_karma_webpack_/main.js /
25 05 2018 16:08:37.342:DEBUG [middleware:source-files]: Fetching /_karma_webpack_/main.js
25 05 2018 16:08:37.342:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/boot.js
25 05 2018 16:08:37.342:DEBUG [web-server]: serving (cached): C:/Users/andrey.chalkin/Allianz/node_modules/karma-jasmine/lib/adapter.js
HeadlessChrome 66.0.3359 (Windows 10.0.0): Executed 0 of 0 ERROR (0.004 secs / 0 secs)

Finished in 0.004 secs / 0 secs @ 16:08:39 GMT+0700 (Tomsk Standard Time)

SUMMARY:
√ 0 tests completed
25 05 2018 16:08:39.143:DEBUG [reporter.coverage-istanbul]: Writing coverage reports: [ 'html', 'clover' ]
25 05 2018 16:09:11.637:DEBUG [launcher]: Disconnecting all browsers
25 05 2018 16:09:11.825:DEBUG [launcher]: Process ChromeHeadless exited with code 0
25 05 2018 16:09:11.835:DEBUG [temp-dir]: Cleaning temp dir C:\Users\ANDREY~1.CHA\AppData\Local\Temp\karma-46718554
25 05 2018 16:09:11.878:DEBUG [launcher]: Finished all browsers

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 25 (8 by maintainers)

Most upvoted comments

Try to change the karma.conf basePath property. I had it with empty value and fixing it with / solved the problem for me. This was failing:

 config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular-devkit/build-angular'],
        .....

This works perfect for me:

 config.set({
        basePath: '/',
        frameworks: ['jasmine', '@angular-devkit/build-angular'],
        .....

I have the same problem, after upgrading. Creating a new project with ng new works fine however, but even copying the karma.conf.js, test.ts, angular.json, tsconf.spec.json and relevant parts of package.json from the working project into my upgraded project and even the app.component.spec.ts I still get same behaviour, Executed 0 of 0 ERROR, I really don’t get what else could be affecting this!

I found solution for my case: Problem whas that we import something from rxjs-compat in polyfills.ts, steps to reproduce:

  1. npm install -g @angular/cli@6.0.7
  2. ng new cli-app
  3. npm install --save rxjs-compat
  4. Add to your polyfills.ts import. For example: import 'rxjs/add/observable/combineLatest';
  5. Try ng test (you’ll see Executed 0 of 0 ERROR)

Steps to resolve:

  1. Move this import to main.ts and test.ts both

@L2jLiga Noooooo I’m so embarrassed. Thanks for pointing out my mistake.

@Nxt3

"test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "apps/federation/src/test.ts",
            "polyfills": "apps/federation/src/polyfills.ts",
            "tsConfig": "apps/federation/tsconfig.app.json",
            "karmaConfig": "apps/federation/karma.conf.js",
            "styles": ["apps/federation/src/styles.scss"],
            "scripts": [],
            "assets": [
              "./apps/federation/src/assets",
              "./apps/federation/src/favicon.ico",
              {
                "glob": "**/*",
                "input": "libs/translate/locale",
                "output": "/libs/locale"
              }
            ]
          }

"tsConfig": "apps/federation/tsconfig.app.json", => "tsConfig": "apps/federation/tsconfig.spec.json",

Facing the same issue here. I’ve spent some time debugging but still have no idea about the source of the problem 😞.