From 358fa27e7b41c40d4439e9c372739c1ea6f52e60 Mon Sep 17 00:00:00 2001 From: juergba Date: Sat, 9 Feb 2019 23:12:21 +0100 Subject: [PATCH] tests after-/Each hooks --- .../pending/skip-sync-after.fixture.js | 18 ++++++++ .../pending/skip-sync-afterEach.fixture.js | 15 +++++++ test/integration/pending.spec.js | 44 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 test/integration/fixtures/pending/skip-sync-after.fixture.js create mode 100644 test/integration/fixtures/pending/skip-sync-afterEach.fixture.js diff --git a/test/integration/fixtures/pending/skip-sync-after.fixture.js b/test/integration/fixtures/pending/skip-sync-after.fixture.js new file mode 100644 index 0000000000..45c6521f3c --- /dev/null +++ b/test/integration/fixtures/pending/skip-sync-after.fixture.js @@ -0,0 +1,18 @@ +'use strict'; + +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'); + }); + + describe('inner suite', function () { + it('should run this test-2', function () {}); + }); +}); + +describe('second suite', function () { + it('should run this test-3', function () {}); +}); diff --git a/test/integration/fixtures/pending/skip-sync-afterEach.fixture.js b/test/integration/fixtures/pending/skip-sync-afterEach.fixture.js new file mode 100644 index 0000000000..aac52875bf --- /dev/null +++ b/test/integration/fixtures/pending/skip-sync-afterEach.fixture.js @@ -0,0 +1,15 @@ +'use strict'; + +describe('skip in afterEach', function () { + it('should run this test-1', function () {}); + it('should run this test-2', function () {}); + + afterEach('should print DeprecationWarning', function () { + this.skip(); + throw new Error('never throws this error'); + }); +}); + +describe('second suite', function () { + it('should run this test-3', function () {}); +}); diff --git a/test/integration/pending.spec.js b/test/integration/pending.spec.js index ea8bd4bf15..2ebc3fbd09 100644 --- a/test/integration/pending.spec.js +++ b/test/integration/pending.spec.js @@ -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', '"after all" 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) { @@ -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', '"after each" 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(