-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make t.log()
behave like console.log()
#1653
Conversation
85ec4ba
to
1214212
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log()
uses util.format()
underneath, which supports placeholder tokens. I couldn't quite find a maintained & ready module that would let us support the same tokens. Perhaps we can leave that as a follow-up.
lib/assert.js
Outdated
@@ -122,8 +122,15 @@ function wrapAssertions(callbacks) { | |||
} | |||
}, | |||
|
|||
log(text) { | |||
log(this, text); | |||
log(...args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the next few months we're still targeting Node.js 4, which doesn't support rest parameters. You'll have to use plain old arguments
instead.
20890be
to
0548a36
Compare
lib/assert.js
Outdated
args.forEach((value, index) => { | ||
args[index] = typeof value === 'string' ? | ||
value : concordance.format(value, concordanceOptions); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're really mapping args
anyway this would be better as:
const args = Array.from(arguments, value => {
// ...
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense! I was trying to find a better way :)
t.log()
behave like console.log()
Thanks @kugtong33! |
Fixes #1635
Use concordance to format all arguments except string arguments as the existing test will fail and I find it awkward this way. Update test to cater
t.log()
andt.log(n1, n2, n3, ...)
.