Skip to content

One failing test causes other async tests to fail in the Karma DEBUG RUNNER #2811

@daanstolp

Description

@daanstolp

Consider the following tests (in Jasmine), where the first is synchronous and the second is asynchronous:

describe("The system", function() {
    
    it("should fail", function() {
        expect(true).toBe(false);
    });

    it("should succeed", function(done) {
        setTimeout(function() {
            expect(1).toBe(1);
            done();
        }, 10);
    });
});

Expected behaviour

  • When I run the tests in the default runner, I expect the first test to fail and the second test to pass.
  • When I run the tests in the Karma DEBUG RUNNER, I expect the first test to fail and the second test to pass.

Actual behaviour

  • When I run the tests in the default runner, the first test fails and the second test passes, as expected.
  • When I run the tests in the Karma DEBUG RUNNER, both tests fail. The error message for the second test is the same failure message that caused the first test to fail:
Uncaught Expected true to be false.
    at UserContext.<anonymous> (http://localhost:9876/base/test.spec.js:4:22) thrown

Environment Details

  • Karma version (output of karma --version): 1.7.0
  • karma.config.js file is default out of the box, configured to load '*.js' files.

Steps to reproduce the behaviour

  1. Create a new application using npm init
  2. npm install karma karma-jasmine jasmine-core karma-chrome-launcher --save-dev
  3. Create a new file called test.spec.js and add the test code that is listed above.
  4. Run karma init and accept all defaults. Enter *.js and *.spec.js as files location.
  5. Add "test": "karma start" to the package.json scripts section.
  6. run npm run test
  7. Click the Debug button to open the Karma DEBUG RUNNER.
  8. In the console of Google Chrome, you can now see the error messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions