Skip to content

Commit

Permalink
Shows object diff when an async assertion fails
Browse files Browse the repository at this point in the history
Before, the assertion failure that mocha could readily interpret was
wrapped when inside an async hook. This made for very not helpful
failures.

This unwraps to prevent this.

See mochajs/mocha#2797
  • Loading branch information
Adrian Cole committed Jun 27, 2019
1 parent cae621a commit 455a2d6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ const chai = require('chai');
chai.config.includeStack = true;
global.expect = chai.expect;

// Otherwise assertion failures in async tests are wrapped, which prevents mocha from
// being able to interpret them (such as displaying a diff).
process.on('unhandledRejection', err => {
throw err;
});

if (process.env.TEST_SUITE === 'browser') {
/* eslint-disable no-console */
console.log('WARN: Skipping nodejs tests because TEST_SUITE is \'browser\'.');
Expand Down

0 comments on commit 455a2d6

Please sign in to comment.