Debugging Karma + PhantomJS

tl;dr: Add the lines highlighted below to karma.conf.js and open http://localhost:9876/debug.html in Chrome (with dev tools open) while your tests are running:


module.exports = function (config) {
    config.set({
        basePath: '',
        frameworks: ['jasmine', 'angular-cli'],
        plugins: [
            require('karma-jasmine'),
            require('karma-phantomjs-launcher'),
            require('angular-cli/plugins/karma')
        ],
        port: 9876,
        browsers: ['PhantomJS'],
        singleRun: false,
        // Allow remote debugging when using PhantomJS
        customLaunchers: {
            'PhantomJS_custom': {
                base: 'PhantomJS',
                debug: true,
            },
        },
    });
};

Keep reading »

permalink