Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'fullTitle() is not a function' in exit.js #388

Merged
merged 1 commit into from
Feb 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/interfaces/bdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ module.exports = function (suite) {
};

context.BeforeSuite = function (fn) {
suites[0].beforeAll('BeforeSuite', scenario.injected(fn));
suites[0].beforeAll('BeforeSuite', scenario.injected(fn, suites[0]));
};

context.AfterSuite = function (fn) {
suites[0].afterAll('AfterSuite', scenario.injected(fn));
suites[0].afterAll('AfterSuite', scenario.injected(fn, suites[0]));
};

context.Background = context.Before = function (fn) {
suites[0].beforeEach('Before', scenario.injected(fn));
suites[0].beforeEach('Before', scenario.injected(fn, suites[0]));
};

context.After = function (fn) {
suites[0].afterEach('After', scenario.injected(fn));
suites[0].afterEach('After', scenario.injected(fn, suites[0]));
};

/**
Expand Down
12 changes: 8 additions & 4 deletions lib/listener/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ let failed = false;

let failedTests = [];

event.dispatcher.on(event.test.failed, function (test) {
failedTests.push(test.fullTitle());
event.dispatcher.on(event.test.failed, function (testOrSuite) {
// NOTE When an error happens in one of the hooks (BeforeAll/BeforeEach...) the event object
// is a suite and not a test
failedTests.push(testOrSuite.fullTitle());
});

// if test was successful after retries
event.dispatcher.on(event.test.passed, function (test) {
failedTests = failedTests.filter((failed) => test.fullTitle() !== failed);
event.dispatcher.on(event.test.passed, function (testOrSuite) {
// NOTE When an error happens in one of the hooks (BeforeAll/BeforeEach...) the event object
// is a suite and not a test
failedTests = failedTests.filter((failed) => testOrSuite.fullTitle() !== failed);
});

event.dispatcher.on(event.all.result, function () {
Expand Down
4 changes: 2 additions & 2 deletions lib/scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ module.exports.test = (test) => {
/**
* Injects arguments to function from controller
*/
module.exports.injected = function (fn) {
module.exports.injected = function (fn, suite) {
return function () {
try {
fn.apply(this, getInjectedArguments(fn));
} catch (err) {
recorder.throw(err);
}
recorder.catch((err) => {
event.emit(event.test.failed, {}, err); // emit
event.emit(event.test.failed, suite, err); // emit
throw err;
});
return recorder.promise();
Expand Down