-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate with improved throws helper
Show instructions on how to use `t.throws()` with the test results, without writing them to stderr. Detect the improper usage even if user code swallows the error, meaning that tests will definitely fail. Assume that errors thrown, or emitted from an observable, or if the returned promise was rejected, that that error is due to the improper usage of `t.throws()`. Assume that if a test has a pending throws assertion, and an error leaks as an uncaught exception or an unhandled rejection, the error was thrown due to the pending throws assertion. Attribute it to the test.
- Loading branch information
1 parent
5e7ea9a
commit d924045
Showing
19 changed files
with
314 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
const chalk = require('chalk'); | ||
|
||
exports.forError = error => { | ||
if (!error.improperUsage) { | ||
return null; | ||
} | ||
|
||
const assertion = error.assertion; | ||
if (assertion !== 'throws' || !assertion === 'notThrows') { | ||
return null; | ||
} | ||
|
||
return `Try wrapping the first argument to \`t.${assertion}()\` in a function: | ||
${chalk.cyan(`t.${assertion}(() => { `)}${chalk.grey('/* your code here */')}${chalk.cyan(' })')} | ||
Visit the following URL for more details: | ||
${chalk.blue.underline('https://github.com/avajs/ava#throwsfunctionpromise-error-message')}`; | ||
}; |
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.