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

Fix this.skip() async calls #3745

Merged
merged 2 commits into from Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/runner.js
Expand Up @@ -781,6 +781,9 @@ Runner.prototype.runSuite = function(suite, fn) {
* @private
*/
Runner.prototype.uncaught = function(err) {
if (err instanceof Pending) {
return;
}
if (err) {
debug('uncaught exception %O', err);
} else {
Expand Down
Expand Up @@ -14,8 +14,7 @@ describe('outer suite', function () {
console.log('inner before');
var self = this;
setTimeout(function () {
self.skip();
done();
self.skip(); // done() is not required
}, 0);
});

Expand Down
Expand Up @@ -2,8 +2,7 @@ describe('skip in before with nested describes', function () {
before(function (done) {
var self = this;
setTimeout(function () {
self.skip();
done();
self.skip(); // done() is not required
}, 0);
});

Expand Down
Expand Up @@ -7,7 +7,7 @@ describe('outer describe', function () {
before(function (done) {
var self = this;
setTimeout(function () {
self.skip();
self.skip(); // done() is not required
}, 0);
});

Expand Down
Expand Up @@ -4,18 +4,17 @@ describe('skip in beforeEach', function () {
beforeEach(function (done) {
var self = this;
setTimeout(function () {
self.skip();
done();
self.skip(); // done() is not required
}, 0);
});

it('should skip this test', function () {
it('should skip this test-1', function () {
throw new Error('never run this test');
});
it('should not reach this test', function () {
it('should skip this test-2', function () {
throw new Error('never run this test');
});
it('should not reach this test', function () {
it('should skip this test-3', function () {
throw new Error('never run this test');
});
});
Expand Up @@ -4,7 +4,7 @@ describe('skip in test', function () {
it('should skip async', function (done) {
var self = this;
setTimeout(function () {
self.skip();
self.skip(); // done() is not required
}, 0);
});

Expand Down
23 changes: 13 additions & 10 deletions test/integration/pending.spec.js
Expand Up @@ -258,18 +258,21 @@ describe('pending', function() {

describe('in beforeEach', function() {
it('should skip all suite specs', function(done) {
run('pending/skip-async-beforeEach.fixture.js', args, function(
err,
res
) {
var fixture = 'pending/skip-async-beforeEach.fixture.js';
run(fixture, args, function(err, res) {
if (err) {
done(err);
return;
return done(err);
}
assert.strictEqual(res.stats.pending, 1);
assert.strictEqual(res.stats.passes, 0);
assert.strictEqual(res.stats.failures, 1);
assert.strictEqual(res.code, 1);
expect(res, 'to have passed')
juergba marked this conversation as resolved.
Show resolved Hide resolved
.and('to have passed test count', 0)
.and('to have pending test count', 3)
.and(
'to have pending test order',
'should skip this test-1',
'should skip this test-2',
'should skip this test-3'
)
.and('to have failed test count', 0);
done();
});
});
Expand Down