Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Tests that call this.skip() are marked as failed instead of skipped #77

Closed
Joris-van-der-Wel opened this issue Oct 10, 2015 · 2 comments

Comments

@Joris-van-der-Wel
Copy link

If this test is executed in karma-mocha:

it('This test should be skipped!', function() {
  this.skip();
});

It will be marked as failed (FAILED This test should be skipped!, Skipped 0 tests). If the test is run using mocha from the command line, the test is marked as pending.

However the followings works as expected in karma-mocha (Skipped 1 tests):

xit('This test should be skipped!', function() {
  ...
});

I stepped through it in the debugger and it seems that mocha tries to emit a "pending" event, however there are no listeners attached to this event.

@maksimr
Copy link
Contributor

maksimr commented Oct 11, 2015

@Joris-van-der-Wel thanks!

@Joris-van-der-Wel
Copy link
Author

I ran into this issue again in my own mocha project, and I remembered this issue.

Here is where this.skip() ends up: lib/runner.js:532. Note that test.pending = true is not set. Only a pending event is fired, which you could use to track a flag for the test and then handle it as skipped in the test end event that karma-mocha already handles.

maksimr added a commit that referenced this issue Nov 13, 2015
fix: Tests that call this.skip() are marked as failed instead of skipped fix #77
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants