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
- Create a new application using
npm init
npm install karma karma-jasmine jasmine-core karma-chrome-launcher --save-dev
- Create a new file called
test.spec.js and add the test code that is listed above.
- Run
karma init and accept all defaults. Enter *.js and *.spec.js as files location.
- Add
"test": "karma start" to the package.json scripts section.
- run
npm run test
- Click the
Debug button to open the Karma DEBUG RUNNER.
- In the console of Google Chrome, you can now see the error messages.
Consider the following tests (in Jasmine), where the first is synchronous and the second is asynchronous:
Expected behaviour
Actual behaviour
Environment Details
karma --version): 1.7.0karma.config.jsfile is default out of the box, configured to load '*.js' files.Steps to reproduce the behaviour
npm initnpm install karma karma-jasmine jasmine-core karma-chrome-launcher --save-devtest.spec.jsand add the test code that is listed above.karma initand accept all defaults. Enter*.jsand*.spec.jsas files location."test": "karma start"to the package.jsonscriptssection.npm run testDebugbutton to open the Karma DEBUG RUNNER.