question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR: Chrome 55.0.2883 (Linux 0.0.0): Executed 0 of 0 ERROR (0.025 secs / 0 secs)

See original GitHub issue

I am using karma/jasmine/webpack combo for setting up the testrunner to work with typescript.

version: “karma-chrome-launcher”: “^2.0.0”

What I list below works for firefox & phantomJS but the unit tests seem to not even run for chrome. Any ideas on what might be the problem here ?

Project structure:

./src/*.ts
./test/*.spec.ts
./index.ts (entry point for ./src/*ts)
./karma.conf.js
./tsconfig.json
./webpack.config.js

For simplicity ignore the src/*.ts files that are being tested. The problem occurs even if a dummy .spec.ts script calls a few empty describe methods.

tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "sourceMap": true,
        "declaration": true,
        "outDir": "bin",
        "types": [
            "karma-jasmine" // required to auto import jasmine from .spec.ts scripts
        ]
    } ,
    "files": [
        "index.ts"
    ]
}

webpack.config.js

var webpack = require('webpack');

module.exports = {  
    entry: './index.ts',
    output: {
        libraryName: 'auvious-focus-client-js',
        libraryTarget: 'umd',
        filename: 'bin/index.umd.js',
        umdNamedDefine: true
    },
    // Turn on sourcemaps
    devtool: 'source-map',
    resolve: {
        extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
    },
    module: {
        loaders: [
            { test: /\.ts$/, loader: 'ts-loader' },
            { test: /\.json$/, loader: 'json-loader' }
        ]
    }
}


karma.conf.js

// Karma configuration
// Generated on Wed Jan 04 2017 13:52:08 GMT+0200 (EET)

var webpackConfig = require('./webpack.config.js');
webpackConfig.entry = {};

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: [
      "jasmine"
    ],


    // list of files / patterns to load in the browser
    files: [
      'test/*.ts'
    ],


    // list of files to exclude
    exclude: [],


    // webpack configuration based on webpack.config.js
    webpack: {
      devtool: webpackConfig.devtool,
      module: webpackConfig.module,
      resolve: webpackConfig.resolve
    },

    webpackMiddleware: {
      // quiet: true,
      stats: {
        colors: true
      }
    },

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
        "test/*.ts": ['webpack', 'sourcemap']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: [
      "progress"
    ],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: [
      'Chrome' // ERROR: Chrome 55.0.2883 (Linux 0.0.0): Executed 0 of 0 ERROR (0.025 secs / 0 secs)
      ,'Firefox'
      // ,'Safari'
      // ,'ChromeCanary'
      ,'PhantomJS'
      // ,'Opera'
      // ,'IE'
    ],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,


    // half sec delay on reruns
    autoWatchBatchDelay: 500,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  });
}

sample .spec.ts

console.info('I am running bro...');
describe('test', () => {
    it('should expect nothing', () => {
        console.info('whatever AA');
        expect(true).toBe(true);
    });
});

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

16reactions
lylejohnsoncommented, Jan 27, 2017

I found a workaround that solved the problem for me. See this comment; in your karma.conf.js file, add:

mime: {
  'text/x-typescript': ['ts','tsx']
},

This tells the Karma server to serve the .ts files with a text/x-typescript mime type. That seems to make it work.

0reactions
SirLantscommented, Oct 1, 2017

@lylejohnson Fixed my problem too. I already had ts preprocessing setup but my tests wouldn’t run in ChromeHeadless until I added this line, thank you so much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Karma not running tests. Executed 0 of 0 ERROR
Wound up just running ng test from C:\Users\king\Desktop\_REPOS\inventivangular which generated its own karma.conf.js and everything worked.
Read more >
T240955 Firefox CI tests keep failing in VE with Firefox 68
0 (Linux 0.0.0) ERROR 14:34:37 Disconnectedreconnect failed before timeout of 5000ms (ping timeout) 14:34:37 Firefox 68.0.0 (Linux 0.0.0): Executed 0 of 0 ......
Read more >
How to setup up test enviroment with Karma and Jasmine
I have this error when run npm test : ... socket /#jDCBhNAJU3mWZHVMAAAA with id 4035564 Chrome 55.0.2883 (Windows 10 0.0.0) ERROR Uncaught ...
Read more >
Debugging Jasmine Unit tests running with Karma runner in ...
07 04 2017 17:17:57.503:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: ... (Mac OS X 10.11.6): Executed 2 of 2SUCCESS (0.025 secs / 0.019...
Read more >
karma-runner/karma - Gitter
it looks like the error is because my tests arent getting in somehow ... HeadlessChrome 0.0.0 (Windows 10 0.0.0): Executed 179 of 220...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found