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

Executed 0 of 0 ERROR even the test spec executed! #1978

Closed
creeperyang opened this issue Mar 8, 2016 · 4 comments
Closed

Executed 0 of 0 ERROR even the test spec executed! #1978

creeperyang opened this issue Mar 8, 2016 · 4 comments

Comments

@creeperyang
Copy link

Expected behavior

The terminal Should log Success.

Actual behavior

The terminal get Executed 0 of 0 ERROR (0.003 secs / 0 secs).

But at http://localhost:9876/debug.html, the console logs:

Skipped 0 tests
SUCCESS when the app starts outputs 'App Started!' in the target
Skipped 0 tests

It's clear that spec is executed.

Enviroment Details

  • karma@0.13.21
  • karma.config.js
    frameworks: ['jasmine'],
    files: [
      'amd.js',
      'test/test-main.js',
      { pattern: 'node_modules/jquery/dist/jquery.js', included: false },
      { pattern: 'demo/*.js', included: false },
      { pattern: 'test/**/*.spec.js', included: false }
    ],
@Florian-R
Copy link

Dupe on #926 (fixed in 0.13.20)

@creeperyang
Copy link
Author

@Florian-R Absolutely not the same thing with #926 .

I mean my tests are executed successfully. And the browser console get correct output but terminal not.

test code xx.spec.js:

define(['demo/app', 'jquery'], function (App, $) {
    describe("when the app starts", function () {
        it("outputs 'App Started!' in the target", function () {
            var target = $("body");

            var app = new App(target);
            app.start();

            expect(target.html()).toEqual("App Started!");
        });
    });
});

The browser output:

SUCCESS when the app starts outputs 'App Started!' in the target

and terminal:

Chrome 49.0.2623 (Mac OS X 10.11.3): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

@Florian-R
Copy link

Indeed, my bad.

I'm not very versed with an AMD setup but it seems to me that you need to require your specs no?

@creeperyang
Copy link
Author

@Florian-R I solved it just now.

I drop karma-requirejs and because I want to test my own amd.js lib. And then I run into the issue above.

So I checked the source code of karma-requirejs and finally I saw what I missed for running test successfully. I write my adapter code and make it a custom plugin. Now everything is ok.

Thanks anyway.


The key point is that we must override window.__karma__.loaded to make it async.

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

2 participants