Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hangs karma #209

Open
avdd opened this issue Feb 6, 2016 · 6 comments
Open

hangs karma #209

avdd opened this issue Feb 6, 2016 · 6 comments

Comments

@avdd
Copy link

avdd commented Feb 6, 2016

when starting karma with callback:

var karma = require('karma');
var opts = {
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
};
new karma.Server(opts, () => null).start();

coverage causes the process to hang after running the tests.

using karma.conf.js:

module.exports = function(config) {
  config.set({
    files: ['test.js'],
    frameworks: ['jasmine'],
    reporters: ['coverage'],
    coverageReporter: {
        reporters: [{type: 'text'}]
    },
    port: 9876,
    browsers: ['PhantomJS'],
    plugins: [
        'karma-jasmine',
        'karma-phantomjs-launcher',
        'karma-coverage'
    ]
  })
}

The process exits normally if either: no callback is passed to the Server constructor, or the coverage reporter is disabled.

I notice there is no change in coverage that caused this issue; it may be related to socketio/socket.io#2368 ?

@bjacobel
Copy link

bjacobel commented Apr 5, 2016

I have this same issue. For me, it seems to be related specifically to the text-summary reporter.

        coverageReporter: {
            dir: 'build', subdir: 'coverage-js',
            reporters: [
                {type: 'html', subdir: 'coverage-js/html'},
                {type: 'cobertura', file: 'coverage.xml'},
                {type: 'lcov', dir: 'coverage/'},
                {type: 'text-summary'}
            ]
        }
$> time npm test
> [email protected] test /Users/bjacobel/code/edx-ui-toolkit
> gulp test

[11:12:17] Using gulpfile ~/code/edx-ui-toolkit/gulpfile.js
[11:12:17] Starting 'test'...
< ... test output>
=============================== Coverage summary ===============================
Statements   : 92.81% ( 774/834 )
Branches     : 65.38% ( 119/182 )
Functions    : 95.51% ( 234/245 )
Lines        : 92.78% ( 771/831 )
================================================================================
[11:12:18] Finished 'test' after 1.89 s

real    0m34.425s
user    0m3.619s
sys 0m0.602s

But after removing the text-summary reporter:

        coverageReporter: {
            dir: 'build', subdir: 'coverage-js',
            reporters: [
                {type: 'html', subdir: 'coverage-js/html'},
                {type: 'cobertura', file: 'coverage.xml'},
                {type: 'lcov', dir: 'coverage/'}
            ]
        }
$> time npm test

> [email protected] test /Users/bjacobel/code/edx-ui-toolkit
> gulp test

[11:13:55] Using gulpfile ~/code/edx-ui-toolkit/gulpfile.js
[11:13:55] Starting 'test'...
< ... test output>
[11:13:56] Finished 'test' after 1.61 s

real    0m3.536s
user    0m3.271s
sys 0m0.451s

(Similar results when using the text reporter as a substitute for text-summary.)

Interestingly, it's not taking that 30sec to produce the coverage output, as the 30sec hang is after the text-summary coverage is output.

@bjacobel
Copy link

bjacobel commented Apr 5, 2016

Oddly the issue goes away if you specify a file for text or text-coverage to write to, e.g., {type: 'text-summary', file: 'coverage.txt'}

@dynisor
Copy link

dynisor commented Jul 1, 2016

This only happens when I run it through gulp. If I change my test script in npm to call karma start --single-run directly the issue never happens anymore. This might actually be an issue with karma-runner/gulp-karma and not this project.

Edit: Actually I wasn't even using gulp-karma just var karma = require('karma').Server;, so an issue with karma itself is also a possibility.

Edit Edit: It's because I'm an idiot and gulp-karma ain't even a thing. Please don't mind my stupidity, point still stands though.

@ecozoic
Copy link

ecozoic commented Aug 22, 2016

Just started seeing this issue today. Running karma server through gulp. Disabling coverage reporter fixes the hang. Seems to happen w/ both HTML and JSON reporters.

UPDATE - Also confirmed that running karma directly from command-line avoids the issue. Seems to be some connection between var karma = require('karma').Server and karma-coverage

@9still
Copy link

9still commented Oct 19, 2016

At least in our case, this appears to have something to do with console output happening after text output is written to the console.

e.g.

...
---------------------------------------------|----------|----------|----------|----------|----------------|
All files                                    |    99.99 |    99.99 |    99.99 |    99.99 |                |
---------------------------------------------|----------|----------|----------|----------|----------------|
LOG: Error blah

will hang, but with

LOG: Error blah
...
---------------------------------------------|----------|----------|----------|----------|----------------|
All files                                    |    99.99 |    99.99 |    99.99 |    99.99 |                |
---------------------------------------------|----------|----------|----------|----------|----------------|

it will not...

For us it also seems to specifically hang within gulp, making me suspect that perhaps something is going haywire with the output stream...?

UPDATE & Workaround: waiting for 3 seconds after test suite completion to make sure any async calls that perform console.log execute before the coverage reporter runs successfully gets around the problem.

@HopefulLlama
Copy link

FWIW: I also found a workaround by installing karma, and using child_process.execSync('node node_modules/karma/bin/karma start --single-run', {stdio: [0, 1, 2]}); inside a gulp task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants