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

Fixing call chaining for before*, after*, it.only, and describe.only #840

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 14 additions & 0 deletions lib/interfaces/bdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,46 @@ module.exports = function(suite){

/**
* Execute before running tests.
*
* @return {Hook} the beforeAll hook for chaining
*/

context.before = function(fn){
suites[0].beforeAll(fn);
return suites[0]._beforeAll.slice(-1)[0];
};

/**
* Execute after running tests.
*
* @return {Hook} the afterAll hook for chaining
*/

context.after = function(fn){
suites[0].afterAll(fn);
return suites[0]._afterAll.slice(-1)[0];
};

/**
* Execute before each test case.
*
* @return {Hook} the beforeEach hook for chaining
*/

context.beforeEach = function(fn){
suites[0].beforeEach(fn);
return suites[0]._beforeEach.slice(-1)[0];
};

/**
* Execute after each test case.
*
* @return {Hook} the afterEach hook for chaining
*/

context.afterEach = function(fn){
suites[0].afterEach(fn);
return suites[0]._afterEach.slice(-1)[0];
};

/**
Expand Down Expand Up @@ -95,6 +107,7 @@ module.exports = function(suite){
context.describe.only = function(title, fn){
var suite = context.describe(title, fn);
mocha.grep(suite.fullTitle());
return suite
};

/**
Expand All @@ -118,6 +131,7 @@ module.exports = function(suite){
context.it.only = function(title, fn){
var test = context.it(title, fn);
mocha.grep(test.fullTitle());
return test
};

/**
Expand Down