-
-
Notifications
You must be signed in to change notification settings - Fork 3k
feat: deprecation message when an async callback is used in a Suite #4921
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
Changes from all commits
9425614
ba71bcb
b7412b3
61e34db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,16 @@ module.exports = function (suites, context, mocha) { | |
throw createUnsupportedError('Pending test forbidden'); | ||
} | ||
if (typeof opts.fn === 'function') { | ||
opts.fn.call(suite); | ||
const suiteResult = opts.fn.call(suite); | ||
if (suiteResult !== undefined) { | ||
errors.deprecate( | ||
'[mocha] Suite "' + | ||
suite.fullTitle() + | ||
'" returned a Promise. ' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Now that it's |
||
'Asynchronous suites are not supported, use a ' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
...and this too. |
||
'synchronous callback instead.' | ||
); | ||
} | ||
suites.shift(); | ||
} else if (typeof opts.fn === 'undefined' && !suite.pending) { | ||
throw createMissingArgumentError( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
describe('a suite with an async callback', async function () {}); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Testing] This has a very clean + good unit test for the async (returning a Promise) case. But since the |
Uh oh!
There was an error while loading. Please reload this page.