Angular-cli: ng test ends with "Executed 0 of 0 ERROR"

Created on 23 Oct 2016  ·  30Comments  ·  Source: angular/angular-cli

I'm using Windows 10 (10.0.14388.0 (rs1_release.160709-1635)), node 6.9.1 and angular-cli 1.0.0-beta.18.

I created a new ng project with angular-cli and ran ng test. I got the following output:

λ ng test
23 10 2016 10:52:02.889:WARN [karma]: No captured browser, open http://localhost:9876/
23 10 2016 10:52:02.897:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
23 10 2016 10:52:02.898:INFO [launcher]: Launching browser Chrome with unlimited concurrency
23 10 2016 10:52:02.909:INFO [launcher]: Starting browser Chrome
23 10 2016 10:52:03.840:INFO [Chrome 55.0.2883 (Windows 10 0.0.0)]: Connected on socket /#1G7vpI_QqAJgLKdyAAAA with id 55321352
Chrome 55.0.2883 (Windows 10 0.0.0): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

I can't see any actual error message from the command line or from Karma's Chrome instance's console.

UPDATE: Actually this might be related to the warning "No capture browser" even though browser seems to open just fine.

more info

Most helpful comment

https://github.com/angular/angular-cli/issues/2125

see @jtsom 's answer:
In the karma.conf.js file, add:
mime: { 'text/x-typescript': ['ts','tsx'] },
works for me.

All 30 comments

More info: I managed to get tests running with PhantomJS. Here's a diff of changes I applied on top of clean new project created by angular-cli:

λ git diff                                                             
warning: LF will be replaced by CRLF in karma.conf.js.                 
The file will have its original line endings in your working directory.
diff --git a/karma.conf.js b/karma.conf.js                             
index e28922a..1e68bfe 100644                                          
--- a/karma.conf.js                                                    
+++ b/karma.conf.js                                                    
@@ -7,7 +7,7 @@ module.exports = function (config) {                   
     frameworks: ['jasmine', 'angular-cli'],                           
     plugins: [                                                        
       require('karma-jasmine'),                                       
-      require('karma-chrome-launcher'),                               
+      require('karma-phantomjs-launcher'),                            
       require('karma-remap-istanbul'),                                
       require('angular-cli/plugins/karma')                            
     ],                                                                
@@ -32,7 +32,7 @@ module.exports = function (config) {                 
     colors: true,                                                     
     logLevel: config.LOG_INFO,                                        
     autoWatch: true,                                                  
-    browsers: ['Chrome'],                                             
+    browsers: ['PhantomJS'],                                          
     singleRun: false                                                  
   });                                                                 
 };                                                                    
diff --git a/package.json b/package.json                               
index 49045ee..47ba454 100644                                          
--- a/package.json                                                     
+++ b/package.json                                                     
@@ -36,6 +36,7 @@                                                      
     "karma-chrome-launcher": "^2.0.0",                                
     "karma-cli": "^1.0.1",                                            
     "karma-jasmine": "^1.0.2",                                        
+    "karma-phantomjs-launcher": "^1.0.2",                             
     "karma-remap-istanbul": "^0.2.1",                                 
     "protractor": "4.0.9",                                            
     "ts-node": "1.2.1",                                               
warning: LF will be replaced by CRLF in package.json.                  
The file will have its original line endings in your working directory.

And here's output from ng test after these changes:

λ ng test
23 10 2016 11:20:32.271:WARN [karma]: No captured browser, open http://localhost:9876/
23 10 2016 11:20:32.280:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
23 10 2016 11:20:32.281:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
23 10 2016 11:20:32.291:INFO [launcher]: Starting browser PhantomJS
23 10 2016 11:20:33.757:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#qeFdT5g9lMDdgEyrAAAA with id 10589115
PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 3 of 3 SUCCESS (0.157 secs / 0.526 secs)

Any ideas what's wrong? Can this problem be reproduced on Linux or macOS?

I have this problem on macOS Sierra

On a fresh project setup, running ng test --watch=false ends in the exact same way

I wonder if its a Chrome 55 problem, as I'm also on Chrome 55

@erikdonohoo Your hunch was correct. I created a new project with angular-cli beta 18 and Chrome 54 and it ran fine:

24 10 2016 12:18:39.227:WARN [karma]: No captured browser, open http://localhost:9876/
24 10 2016 12:18:39.235:WARN [karma]: Port 9876 in use
24 10 2016 12:18:39.237:INFO [karma]: Karma v1.2.0 server started at http://localhost:9877/
24 10 2016 12:18:39.238:INFO [launcher]: Launching browser Chrome with unlimited concurrency
24 10 2016 12:18:39.294:INFO [launcher]: Starting browser Chrome
24 10 2016 12:18:41.182:INFO [Chrome 54.0.2840 (Windows 10 0.0.0)]: Connected on socket /#ocdvVd7R6QGHxgnXAAAA with id 96648423
Chrome 54.0.2840 (Windows 10 0.0.0): Executed 3 of 3 SUCCESS (0.157 secs / 0.15 secs)

As soon as I updated to Chrome 55 (which is beta btw), I managed to reproduce the problem:

24 10 2016 12:33:06.002:WARN [karma]: No captured browser, open http://localhost:9876/
24 10 2016 12:33:06.015:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
24 10 2016 12:33:06.016:INFO [launcher]: Launching browser Chrome with unlimited concurrency
24 10 2016 12:33:06.026:INFO [launcher]: Starting browser Chrome
24 10 2016 12:33:07.530:INFO [Chrome 55.0.2883 (Windows 10 0.0.0)]: Connected on socket /#nw4KgkJ_-Xo5O9ziAAAA with id 82518644
Chrome 55.0.2883 (Windows 10 0.0.0): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

There seems to be something strange with the configuration generated with angular-cli. I have another proprietary project which isn't generated with angular-cli and with it Karma runs tests in Chrome 55 just fine:

> karma start --browsers Chrome

24 10 2016 12:33:49.025:INFO [preprocessor.karma-typescript]: Using Typescript 2.0.3
24 10 2016 12:33:51.167:WARN [karma]: No captured browser, open http://localhost:9876/
24 10 2016 12:33:51.176:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
24 10 2016 12:33:51.176:INFO [launcher]: Launching browser Chrome with unlimited concurrency
24 10 2016 12:33:51.237:INFO [launcher]: Starting browser Chrome
24 10 2016 12:33:51.890:INFO [Chrome 55.0.2883 (Windows 10 0.0.0)]: Connected on socket /#VJ7Qv4cFsOzTneT4AAAA with id 17303171
Chrome 55.0.2883 (Windows 10 0.0.0): Executed 102 of 102 SUCCESS (0.273 secs / 0.219 secs)

As this is a proprietary project, I'm not at liberty to provide a public repo but here are package.json and karma.conf.js from that project if they provide any additional insight: https://gist.github.com/VilleSalonen/ad5b4c9b442d810ffcbff39faac8a868

I tested whether the problem is with Karma v1.2.0 used by angular-cli's configuration by upgrading manually to v1.3.0 but the problem persists:

24 10 2016 12:35:40.720:WARN [karma]: No captured browser, open http://localhost:9876/
24 10 2016 12:35:40.728:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
24 10 2016 12:35:40.730:INFO [launcher]: Launching browser Chrome with unlimited concurrency
24 10 2016 12:35:40.737:INFO [launcher]: Starting browser Chrome
24 10 2016 12:35:42.204:INFO [Chrome 55.0.2883 (Windows 10 0.0.0)]: Connected on socket /#RK-kdDC1XbvATKccAAAA with id 10819690
Chrome 55.0.2883 (Windows 10 0.0.0): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

I suppose the most obvious difference is the Karma version. The CLI doesn't do anything specific regarding tests, it just starts karma and runs a webpack plugin to compile the specs.

Can you test if updating the versions of Karma and plugins used helps with Chrome 55?

@filipesilva I will test that and report back

this one is biting us now that 55 is rolling out...

Just wondering what the status on this is. I upgraded Chrome last night unaware of it and getting the following:
Chrome 55.0.2883 (Mac OS X 10.12.1): Executed 0 of 0 ERROR (0.003 secs / 0 secs)
results when running ng test

that is the status... we're manually rolling back to 54 for now to get around the issue.

I haven't figured out if it's the way the cli configures karma or if it's the karma chrome plugin -- karma-chrome-launcher

I am having this same issue... Attempted upgrade to Karma 1.3.0 and have the same results.

07 12 2016 16:25:41.080:WARN [karma]: No captured browser, open http://localhost:9876/
07 12 2016 16:25:41.089:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
07 12 2016 16:25:41.089:INFO [launcher]: Launching browser Chrome with unlimited concurrency
07 12 2016 16:25:41.094:INFO [launcher]: Starting browser Chrome
07 12 2016 16:25:41.775:INFO [Chrome 55.0.2883 (Linux 0.0.0)]: Connected on socket /#mTXMXUXUJ6BFMTYtAAAA with id 30
017819
Chrome 55.0.2883 (Linux 0.0.0): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

https://github.com/angular/angular-cli/issues/2125

see @jtsom 's answer:
In the karma.conf.js file, add:
mime: { 'text/x-typescript': ['ts','tsx'] },
works for me.

My patch to add this to the CLI was approved recently - new projects should include it. Older ones will need to add it.

I still have the same error, and in my karma.conf.js I already have the mime defined

mime: { 'text/x-typescript': ['ts','tsx'] }, works for me, thanks @penghuili

This works on Chrome 55.0.2883. Thanks @penghuili

@sebastiannm Many people report that mime setting fixes the problem. Are you sure that it doesn't fix it for you? If you are could you post your whole karm.conf.js?

@VilleSalonen I used the latest angular-cli and that came with it:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', 'angular-cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-remap-istanbul'),
      require('angular-cli/plugins/karma')
    ],
    files: [
      { pattern: './src/test.ts', watched: false }
    ],
    preprocessors: {
      './src/test.ts': ['angular-cli']
    },
    mime: {
      'text/x-typescript': ['ts','tsx']
    },
    remapIstanbulReporter: {
      reports: {
        html: 'coverage',
        lcovonly: './coverage/coverage.lcov'
      }
    },
    angularCli: {
      config: './angular-cli.json',
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
              ? ['progress', 'karma-remap-istanbul']
              : ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

@sebastiannm Did you try it on a brand new angular-cli project without making any changes to it? I'm using Windows 10, angular-cli beta 22.1, node 7.2.1 and Chrome 56.0.2924.21 beta (64-bit) and ng test works fine: Chrome 56.0.2924 (Windows 10 0.0.0): Executed 3 of 3 SUCCESS (0.227 secs / 0.221 secs) My karma.conf.js is identical to yours.

What platform are you running on?

@VilleSalonen Ok the issue was on my test, because I migrated from angular-seed and they follow a different structure apparently. So I actually, I had no tests.

Thanks

Okay, good to know. Then the issue has been resolved.

I came across the same problem, Chrome Version: 55.0.2883.87. Mime Type fixed the problem for me. Thanks a lot for that...

Same here ! :)

Chrome 55 gave me the same problem, thanks for the PhantomJS workaround. Unfortunately I get automatic updates on my workstation and similar issues happen quite often

For anybody arriving here even though they don't use Angular while searching for this error, adding mime: { 'text/x-typescript': ['ts','tsx'] } to karma.conf.js did indeed fix it for me when using a Chrome version of 55.

I had the same issue in Chrome version 56.
Setting the mime fixed it as well.

Guys, I'm having the same issue, but adding the mime it seems just to get worse: instead of getting "Executed 0 of 0 ERROR" I just get "Chrome 56.0.2924 (Windows 10 0.0.0) ERROR". Anywan having a clue on what's going on? Thanks!

Same setup and issue for me as @alextorino

had the same error as @alextorino and @utahdoug
tested with both Chrome 56.0.2924 and Firefox 51.0.0
updating Karma and plugins to latest didn't help

tested a fresh ng new foobar (after updating updating angular-cli -g) and ng test ran fine
so did a 'manual' compare between my project and the new foobar-project, updated numerous files, did a clean npm install
it took a while but it works now

On npm test I am getting below error -

Chrome 62.0.3202 (Windows 10 0.0.0) ERROR: '[Script Loader]', ReferenceError{}
Chrome 62.0.3202 (Windows 10 0.0.0): Executed 33 of 33 SUCCESS (3.196 secs / 3.132 secs)

Updated angular from 5 to 7 after that tried running test with command ng test and getting error "no spec found" and Chrome 73.0.3683 (Linux 0.0.0): Executed 0 of 0 ERROR (0.029 secs / 0 secs).
Can anyone help me how to fix this? i have tried all possible scenarios to fix this

my cli version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _| | | | |/ _ | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ __| |_|__, |__,_|_|__,_|_| ____|_____|___|
|___/

Angular CLI: 7.3.9
Node: 8.16.0
OS: linux x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.12.4
@angular-devkit/build-angular 0.12.4
@angular-devkit/build-optimizer 0.12.4
@angular-devkit/build-webpack 0.12.4
@angular-devkit/core 7.2.4
@angular-devkit/schematics 7.3.9
@angular/cdk 7.3.1
@angular/cli 7.3.9
@angular/flex-layout 7.0.0-beta.23
@angular/material 7.3.1
@ngtools/webpack 7.2.4
@schematics/angular 7.3.9
@schematics/update 0.13.9
rxjs 6.5.2
typescript 3.2.4
webpack 4.28.4

my karma.conf.js:

const tags = process.argv.filter(arg => {
return (arg.endsWith('.component') || arg.endsWith('.service'))
})

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-spec-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),

    ],
    mime: {
        'text/x-typescript': ['ts', 'tsx']
    },
    client: {
        args: [tags],
        clearContext: false // leave Jasmine Spec Runner output visible in browser!
    },
    coverageIstanbulReporter: {
        dir: require('path').join(__dirname, 'coverage'),
        reports: ['html', 'lcovonly'],
        fixWebpackSourcePaths: true
    },

    // reporters: ['progress', 'kjhtml', 'spec'],
    reporters: ['kjhtml', 'spec'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    captureTimeout: 240000,
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 3,
    browserNoActivityTimeout: 60000,
});

};

PS: removed files and the preprocessor configs from the karma.conf.js completely. This is all defined in the angular.json and should be handled automatically by the @anguler-devkit karma plugin

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hartjo picture hartjo  ·  3Comments

JanStureNielsen picture JanStureNielsen  ·  3Comments

donaldallen picture donaldallen  ·  3Comments

jmurphzyo picture jmurphzyo  ·  3Comments

delasteve picture delasteve  ·  3Comments