Skip to content

Commit 594bb52

Browse files
committed
extend existing tests
1 parent be04321 commit 594bb52

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
'use strict';
2+
var assert = require('assert');
23

34
describe('skip in test', function () {
5+
var runOrder = [];
6+
beforeEach(function () {
7+
runOrder.push('beforeEach');
8+
});
9+
410
it('should skip async', function (done) {
511
var self = this;
612
setTimeout(function () {
713
self.skip(); // done() is not required
814
}, 0);
915
});
16+
it('should run other tests in suite', function () {});
1017

11-
it('should run other tests in the suite', function () {});
18+
afterEach(function() {
19+
runOrder.push('afterEach');
20+
});
21+
after(function() {
22+
runOrder.push('after');
23+
assert.deepStrictEqual(runOrder, [
24+
'beforeEach', 'afterEach',
25+
'beforeEach', 'afterEach',
26+
'after'
27+
]);
28+
throw new Error('should throw this error');
29+
});
1230
});
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
'use strict';
2+
var assert = require('assert');
23

34
describe('skip in test', function () {
5+
var runOrder = [];
6+
beforeEach(function () {
7+
runOrder.push('beforeEach');
8+
});
9+
410
it('should skip immediately', function () {
511
this.skip();
612
throw new Error('never run this test');
713
});
14+
it('should run other tests in suite', function () {});
815

9-
it('should run other tests in the suite', function () {});
16+
afterEach(function() {
17+
runOrder.push('afterEach');
18+
});
19+
after(function() {
20+
runOrder.push('after');
21+
assert.deepStrictEqual(runOrder, [
22+
'beforeEach', 'afterEach',
23+
'beforeEach', 'afterEach',
24+
'after'
25+
]);
26+
throw new Error('should throw this error');
27+
});
1028
});

test/integration/pending.spec.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ describe('pending', function() {
5959
it('should immediately skip the spec and run all others', function(done) {
6060
run('pending/skip-sync-spec.fixture.js', args, function(err, res) {
6161
if (err) {
62-
done(err);
63-
return;
62+
return done(err);
6463
}
65-
assert.strictEqual(res.stats.pending, 1);
66-
assert.strictEqual(res.stats.passes, 1);
67-
assert.strictEqual(res.stats.failures, 0);
68-
assert.strictEqual(res.code, 0);
64+
expect(res, 'to have failed with error', 'should throw this error')
65+
.and('to have failed test count', 1)
66+
.and('to have pending test count', 1)
67+
.and('to have pending test order', 'should skip immediately')
68+
.and('to have passed test count', 1)
69+
.and('to have passed tests', 'should run other tests in suite');
6970
done();
7071
});
7172
});
@@ -192,13 +193,14 @@ describe('pending', function() {
192193
it('should immediately skip the spec and run all others', function(done) {
193194
run('pending/skip-async-spec.fixture.js', args, function(err, res) {
194195
if (err) {
195-
done(err);
196-
return;
196+
return done(err);
197197
}
198-
assert.strictEqual(res.stats.pending, 1);
199-
assert.strictEqual(res.stats.passes, 1);
200-
assert.strictEqual(res.stats.failures, 0);
201-
assert.strictEqual(res.code, 0);
198+
expect(res, 'to have failed with error', 'should throw this error')
199+
.and('to have failed test count', 1)
200+
.and('to have pending test count', 1)
201+
.and('to have pending test order', 'should skip async')
202+
.and('to have passed test count', 1)
203+
.and('to have passed tests', 'should run other tests in suite');
202204
done();
203205
});
204206
});

0 commit comments

Comments
 (0)