Skip to content

Commit

Permalink
tests after-/Each hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Feb 11, 2019
1 parent 9d98ff8 commit a63e6d1
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/integration/fixtures/pending/skip-sync-after.fixture.js
@@ -0,0 +1,37 @@
'use strict';
var assert = require('assert');

describe('skip in after', function () {
it('should run this test-1', function () {});

after('should print DeprecationWarning', function () {
this.skip();
throw new Error('never throws this error');
});
after('test should not be marked as pending', function () {
assert(this.currentTest.title === 'should run this test-1');
assert(this.currentTest.state === 'passed');
assert(this.currentTest.pending === false);
});


describe('inner suite', function () {
it('should run this test-2', function () {});

after('test should not be marked as pending', function () {
assert(this.currentTest.title === 'should run this test-2');
assert(this.currentTest.state === 'passed');
assert(this.currentTest.pending === false);
});
});
});

describe('second suite', function () {
it('should run this test-3', function () {});

after('test should not be marked as pending', function () {
assert(this.currentTest.title === 'should run this test-3');
assert(this.currentTest.state === 'passed');
assert(this.currentTest.pending === false);
});
});
28 changes: 28 additions & 0 deletions test/integration/fixtures/pending/skip-sync-afterEach.fixture.js
@@ -0,0 +1,28 @@
'use strict';
var assert = require('assert');

describe('skip in afterEach', function () {
var n = 0;
it('should run this test-1', function () {n = 1;});
it('should run this test-2', function () {n = 2;});

afterEach('should print DeprecationWarning', function () {
this.skip();
throw new Error('never throws this error');
});
afterEach('test should not be marked as pending', function () {
assert(this.currentTest.title === 'should run this test-' + n);
assert(this.currentTest.state === 'passed');
assert(this.currentTest.pending === false);
});
});

describe('second suite', function () {
it('should run this test-3', function () {});

afterEach('test should not be marked as pending', function () {
assert(this.currentTest.title === 'should run this test-3');
assert(this.currentTest.state === 'passed');
assert(this.currentTest.pending === false);
});
});
44 changes: 44 additions & 0 deletions test/integration/pending.spec.js
Expand Up @@ -71,6 +71,28 @@ describe('pending', function() {
});
});

describe('in after', function() {
it('should run all tests', function(done) {
runMocha(
'pending/skip-sync-after.fixture.js',
args,
function(err, res) {
if (err) {
return done(err);
}
expect(res, 'to have passed').and('to satisfy', {
passing: 3,
failing: 0,
pending: 0,
output: expect.it('to contain', "'afterAll' hook is DEPRECATED")
});
done();
},
'pipe'
);
});
});

describe('in before', function() {
it('should skip all suite specs', function(done) {
run('pending/skip-sync-before.fixture.js', args, function(err, res) {
Expand Down Expand Up @@ -145,6 +167,28 @@ describe('pending', function() {
});
});

describe('in afterEach', function() {
it('should run all tests', function(done) {
runMocha(
'pending/skip-sync-afterEach.fixture.js',
args,
function(err, res) {
if (err) {
return done(err);
}
expect(res, 'to have passed').and('to satisfy', {
passing: 3,
failing: 0,
pending: 0,
output: expect.it('to contain', "'afterEach' hook is DEPRECATED")
});
done();
},
'pipe'
);
});
});

describe('in beforeEach', function() {
it('should skip all suite specs', function(done) {
run('pending/skip-sync-beforeEach.fixture.js', args, function(
Expand Down

0 comments on commit a63e6d1

Please sign in to comment.