lazd / gulp-karma

Karma plugin for gulp
MIT License
75 stars 36 forks source link

"Adapter did not report total number of specs." #1

Closed travm closed 10 years ago

travm commented 10 years ago

I've ran into an issue where Karma isn't reporting the total number of tests, even though it is successfully running the tests and reporting back if they have succeeded or failed.

For example, it will run and give me the message "Adapter did not report total number of specs" followed by "Executed 2 of 0. SUCCESS".

While running the karma.conf.js with Karma alone - it appears to correctly calculate the number of tests correctly and the adapter message is not displayed. I have searched around and I have been unable to find anyone else with the same issue. So, I'm afraid that I have either missed a step when setting up Karma in my gulpfile or there may be a bug in the plugin.

Can you take a look at this?

gulpfile.js

gulp.task('tests', function() {
    return gulp.src('./tests/unit-tests.js')
        .pipe(karma({
            configFile: 'karma.conf.js', 
            action: 'run'
        }));
});

karma.conf.js

module.exports = function(config) {
  config.set({
    basePath: '',
    plugins: [
      'karma-qunit',
      'karma-phantomjs-launcher'
    ],
    frameworks: ['qunit'],
    // files: [
    //   'tests/*.js'
    // ],
    exclude: [

    ],
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['PhantomJS'],
    captureTimeout: 60000,
    singleRun: false
  });
};

Thanks!

lazd commented 10 years ago

This is odd, can you post some code that reproduces this? I think there may be a problem with your qunit tests, as it's complaining about the adaptor...

travm commented 10 years ago

That could be it! I was actually just using basic test examples. When ran with Karma, they appear to work as expected. gulp-karma seems to run them and they succeed fine, it just doesn't report the total number. Wasn't sure how to track down the cause.

test("hello world", function() {
    equal(2, 2, "Testing"); 
});

test("hello again", function() {
    equal(1, 1, "Another Test"); 
});
Somarriba commented 10 years ago

I have the same issue and I can't figure it out. Did you ever come up with a solution?

Thank you!

jimthedev commented 10 years ago

I also am experiencing this issue on Mac OSX 10.9. Node v0.10.21. Gulp 3.5.6.

lazd commented 10 years ago

@jcummins, @Somarriba, can you create a repo with minimal code that reproduces this issue?

jimthedev commented 10 years ago

@lazd Sure. I'll give at a shot.

jimthedev commented 10 years ago

Ok @lazd here is the repo: https://github.com/jcummins/gulp-karma-qunit-total-tests-error/

I added the exact commands I am running to the README.md

lazd commented 10 years ago

@jcummins, thanks for putting this together, but with your repo, the same error happens when you use karma start. This is not a gulp-karma issue, unfortunately.

I did some digging and found out that Karma expects to have the total number of specs up front, but that's not possible with qunit. See the links below for more details.

karma-qunit issue: https://github.com/karma-runner/karma-qunit/issues/8

blocking qunit issue: https://github.com/jquery/qunit/issues/350

StackOverflow: http://stackoverflow.com/questions/22455822/adapter-did-not-report-total-number-of-specs-message

karma-users: https://groups.google.com/forum/#!topic/karma-users/or-gWh7cjZc

@travm, I can't see how it would be possible for this to have ever worked correctly when you ran a karma start. Looking at the code in the qunit adaptor and Karma itself, that situation seems impossible. If you are able to get the correct number of specs reported without the warning when running karma start, but not when running gulp, please put together a minimal repo like @jcummins did so I can poke further.

jimthedev commented 10 years ago

@lazd Thanks for looking at this and finding the blocking issue. I'll head over there to see if we can get upstream to implement this.