-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix runtime order for cases where beforeAll fails
In this case, afterAll should run but not the test or any subordinate tests. In the case of outright-skipped test functions we print "SKIPPED"
- Loading branch information
Showing
5 changed files
with
116 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var _ = require('lodash') | ||
global.__results = {} | ||
|
||
// This is a dye test to verify that all the expected hooks ran (or didn't) | ||
module.exports = { | ||
happy: { | ||
beforeAll: mark('happy.beforeAll'), | ||
beforeEach: mark('happy.beforeEach'), | ||
test: mark('happy.test'), | ||
afterEach: mark('happy.afterEach'), | ||
afterAll: mark('happy.afterAll') | ||
}, | ||
beforeAllFails: { | ||
nest: { | ||
beforeAll: mark('beforeAllFails.nest.beforeAll'), | ||
beforeEach: mark('beforeAllFails.nest.beforeEach'), | ||
test: mark('beforeAllFails.nest.test'), | ||
afterEach: mark('beforeAllFails.nest.afterEach'), | ||
afterAll: mark('beforeAllFails.nest.afterAll') | ||
}, | ||
beforeAll: fail('beforeAllFails.beforeAll'), | ||
beforeEach: mark('beforeAllFails.beforeEach'), | ||
test: mark('beforeAllFails.test'), | ||
afterEach: mark('beforeAllFails.afterEach'), | ||
afterAll: mark('beforeAllFails.afterAll') | ||
} | ||
} | ||
|
||
function mark (path) { | ||
_.set(global.__results, path, false) | ||
return function () { | ||
_.set(global.__results, path, true) | ||
} | ||
} | ||
|
||
function fail (path) { | ||
_.set(global.__results, path, false) | ||
return function () { | ||
_.set(global.__results, path, 'fail') | ||
throw new Error('Intentional failure at ' + path) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var helper = require('./support/helper') | ||
|
||
module.exports = function (cb) { | ||
helper.run('test/fixtures/reliable-hooks.js', function (er, result, log) { | ||
helper.deepEqual(global.__results.happy, { | ||
beforeAll: true, | ||
beforeEach: true, | ||
test: true, | ||
afterEach: true, | ||
afterAll: true | ||
}) | ||
|
||
helper.deepEqual(global.__results.beforeAllFails, { | ||
beforeAll: 'fail', | ||
beforeEach: false, | ||
test: false, | ||
afterEach: false, | ||
afterAll: true, | ||
nest: { | ||
beforeAll: false, | ||
beforeEach: false, | ||
test: false, | ||
afterEach: false, | ||
afterAll: false | ||
} | ||
}) | ||
|
||
delete global.__results | ||
cb(er) | ||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters