Skip to content

Commit

Permalink
[Breaking] error should not emit expected/actual diags
Browse files Browse the repository at this point in the history
  • Loading branch information
rhendric authored and ljharb committed Jan 6, 2019
1 parent dff5f1f commit f6dc34e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ function error(err, msg, extra) {
this._assert(!err, {
message : defined(msg, String(err)),
operator : 'error',
actual : err,
error : err,
extra : extra
});
}
Expand Down
4 changes: 0 additions & 4 deletions test/async-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ tap.test('async4', function (t) {
'not ok 2 Error: oops',
' ---',
' operator: error',
' expected: |-',
' undefined',
' actual: |-',
' [Error: oops]',
' at: Test.myTest ($TEST/async-await/async4.js:$LINE:$COL)',
' stack: |-',
' Error: oops',
Expand Down
36 changes: 36 additions & 0 deletions test/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');

var stripFullStack = require('./common').stripFullStack;

tap.test('failures', function (tt) {
tt.plan(1);

var test = tape.createHarness();
test.createStream().pipe(concat(function (body) {
tt.equal(
stripFullStack(body.toString('utf8')),
'TAP version 13\n'
+ '# error\n'
+ 'not ok 1 Error: this is a message\n'
+ ' ---\n'
+ ' operator: error\n'
+ ' at: Test.<anonymous> ($TEST/error.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: this is a message\n'
+ ' at Test.<anonymous> ($TEST/error.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ '\n1..1\n'
+ '# tests 1\n'
+ '# pass 0\n'
+ '# fail 1\n'
);
}));

test('error', function (t) {
t.plan(1);
t.error(new Error('this is a message'));
});
});
12 changes: 2 additions & 10 deletions test/stackTrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ tap.test('preserves stack trace with newlines', function (tt) {
name: "Error: Preserve stack",
diag: {
stack: stackTrace,
operator: 'error',
expected: 'undefined',
actual: '[Error: Preserve stack]'
operator: 'error'
}
});
});
Expand All @@ -37,10 +35,6 @@ tap.test('preserves stack trace with newlines', function (tt) {
+ 'not ok 1 Error: Preserve stack\n'
+ ' ---\n'
+ ' operator: error\n'
+ ' expected: |-\n'
+ ' undefined\n'
+ ' actual: |-\n'
+ ' [Error: Preserve stack]\n'
+ ' stack: |-\n'
+ ' foo\n'
+ ' bar\n'
Expand All @@ -54,9 +48,7 @@ tap.test('preserves stack trace with newlines', function (tt) {

tt.deepEqual(getDiag(body), {
stack: stackTrace,
operator: 'error',
expected: 'undefined',
actual: '[Error: Preserve stack]'
operator: 'error'
});
}));

Expand Down

0 comments on commit f6dc34e

Please sign in to comment.