Browse Source

Merge pull request #354 from sindresorhus/fix-error-stacks

Show full stack trace for non-assert errors
babel-plugin-for-integration-tests
Sindre Sorhus 9 years ago
parent
commit
945dbea40a
  1. 6
      api.js
  2. 7
      lib/test.js
  3. 3
      test/promise.js

6
api.js

@ -83,8 +83,14 @@ Api.prototype._handleTest = function (test) {
if (test.error.originalMessage) { if (test.error.originalMessage) {
message = test.error.originalMessage + ' ' + message; message = test.error.originalMessage + ' ' + message;
} }
test.error.message = message; test.error.message = message;
} }
if (test.error.name !== 'AssertionError') {
test.error.message = 'failed with "' + test.error.message + '"';
}
this.errors.push(test); this.errors.push(test);
} else { } else {
test.error = null; test.error = null;

7
lib/test.js

@ -125,12 +125,7 @@ Test.prototype.run = function () {
self.exit(); self.exit();
}) })
.catch(function (err) { .catch(function (err) {
self._setAssertError(new assert.AssertionError({ self._setAssertError(err);
actual: err,
message: 'Promise rejected → ' + err,
operator: 'promise'
}));
self.exit(); self.exit();
}); });
} else if (!this.metadata.callback) { } else if (!this.metadata.callback) {

3
test/promise.js

@ -245,7 +245,8 @@ test('reject', function (t) {
}); });
}).run().catch(function (err) { }).run().catch(function (err) {
t.ok(err); t.ok(err);
t.is(err.name, 'AssertionError'); t.is(err.name, 'Error');
t.is(err.message, 'unicorn');
t.end(); t.end();
}); });
}); });

Loading…
Cancel
Save