🌐 AI搜索 & 代理 主页
Skip to content

Commit b57f623

Browse files
silviomboneskull
authored andcommitted
fix: When using --delay, .only() no longer works. Issue #1838
1 parent cd74322 commit b57f623

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

lib/runner.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,18 +810,17 @@ Runner.prototype.run = function (fn) {
810810
var self = this;
811811
var rootSuite = this.suite;
812812

813-
// If there is an `only` filter
814-
if (hasOnly(rootSuite)) {
815-
filterOnly(rootSuite);
816-
}
817-
818813
fn = fn || function () {};
819814

820815
function uncaught (err) {
821816
self.uncaught(err);
822817
}
823818

824819
function start () {
820+
// If there is an `only` filter
821+
if (hasOnly(rootSuite)) {
822+
filterOnly(rootSuite);
823+
}
825824
self.started = true;
826825
self.emit('start');
827826
self.runSuite(rootSuite, function () {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
var assert = require('assert');
4+
var delay = 200;
5+
6+
setTimeout(function () {
7+
describe('delayed execution should execute exclusive tests only', function () {
8+
it('should not run this test', function () {
9+
(true).should.equal(false);
10+
});
11+
12+
it.only('should run this', function () {});
13+
14+
it('should not run this test, neither', function () {
15+
(true).should.equal(false);
16+
});
17+
18+
it.only('should run this, too', function () {});
19+
});
20+
21+
run();
22+
}, delay);
23+
24+

test/integration/options.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,25 @@ describe('options', function () {
162162
});
163163
});
164164

165+
it('should execute exclusive tests only', function (done) {
166+
run('options/delay-only.fixture.js', args, function (err, res) {
167+
if (err) {
168+
done(err);
169+
return;
170+
}
171+
172+
assert.equal(res.stats.tests, 2);
173+
assert.equal(res.stats.pending, 0);
174+
assert.equal(res.stats.passes, 2);
175+
assert.equal(res.stats.failures, 0);
176+
177+
assert.equal(res.passes[0].title, 'should run this');
178+
assert.equal(res.passes[1].title, 'should run this, too');
179+
assert.equal(res.code, 0);
180+
done();
181+
});
182+
});
183+
165184
it('should throw an error if the test suite failed to run', function (done) {
166185
run('options/delay-fail.fixture.js', args, function (err, res) {
167186
if (err) {

0 commit comments

Comments
 (0)