add methods to custom and buffered consoles#5514
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5514 +/- ##
==========================================
+ Coverage 61.69% 61.69% +<.01%
==========================================
Files 213 213
Lines 7077 7143 +66
Branches 4 3 -1
==========================================
+ Hits 4366 4407 +41
- Misses 2710 2735 +25
Partials 1 1
Continue to review full report at Codecov.
|
| _console | ||
| .getBuffer() | ||
| .map(log => log.message) | ||
| .join('\n'); |
There was a problem hiding this comment.
you can use strip-ansi here to avoid having to use chalk inline. up to you 🙂
There was a problem hiding this comment.
Yes, maybe it's the way to go, but that way we don't test the bold effect.
WDYT?
|
|
||
| beforeEach(() => { | ||
| _console = new CustomConsole(process.stdout, process.stderr); | ||
| // override the _logToParentConsole method to be able and assert on the stdout. |
There was a problem hiding this comment.
You can use jest.spyOn instead, perhaps?
There was a problem hiding this comment.
Yes, indeed, thanks.
| info() { | ||
| BufferedConsole.write(this._buffer, 'info', format.apply(null, arguments)); | ||
| debug(...args: Array<mixed>) { | ||
| this._log('debug', format.apply(null, arguments)); |
There was a problem hiding this comment.
any reason this (and the others) are still format.apply(null, arguments) instead of format(...args)?
There was a problem hiding this comment.
We can change it to format(...args) everywhere, but then we'll need to change the flow notation...args: Array<mixed> to ...args: Array<string>.
There was a problem hiding this comment.
If we'll decide to go with changing the signature's type notation, we'll need to also do it in the console type definition. Maybe i'm getting something wrong here, I would love to know your thoughts on this.
There was a problem hiding this comment.
thinking about it, doing console.log({}) is perfectly valid, so mixed is correct
There was a problem hiding this comment.
That's true.
What do you say about (...args: Array<any>) and format(...args)?
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
👋 Hey
This PR solves issue #3756.
Summary
The addition of missing methods to
custom consoleandbuffered console.Test plan
_logToParentConsolemethod.concerns
custom consoleandbuffered console.log,warn,info) aren't tested, should we get full coverage there?console.tablemethod is missing.Let me know what can be improved, thanks!