Skip to content

Commit 32f28a3

Browse files
committed
Issue avajs#1125 - Check if assertion message is a string
1 parent 410cb8d commit 32f28a3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: lib/assert.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ function test(ok, opts) {
3030
}
3131
}
3232

33+
function stringMsg(msg) {
34+
if(msg instanceof Error){
35+
return msg.message
36+
}
37+
return msg;
38+
}
39+
3340
x.pass = msg => {
3441
test(true, create(true, true, 'pass', msg, x.pass));
3542
};
3643

3744
x.fail = msg => {
38-
msg = msg || 'Test failed via t.fail()';
45+
msg = stringMsg(msg) || 'Test failed via t.fail()';
3946
test(false, create(false, false, 'fail', msg, x.fail));
4047
};
4148

0 commit comments

Comments
 (0)