Skip to content

Commit

Permalink
Add "debug" method to console (#5350)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjesun authored Jan 19, 2018
1 parent 5943dc9 commit 7f715c8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Fixes

* `[jest-util]` Add "debug" method to "console" implementations
([#5350](https://github.com/facebook/jest/pull/5350))
* `[jest-resolve]` Add condition to avoid infinite loop when node module package main is ".".
([#5344)](https://github.com/facebook/jest/pull/5344)

Expand Down
4 changes: 4 additions & 0 deletions packages/jest-util/src/Console.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export default class CustomConsole extends Console {
super.log(this._formatBuffer(type, message));
}

debug(...args: Array<mixed>) {
this._log('debug', format.apply(null, arguments));
}

log(...args: Array<mixed>) {
this._log('log', format.apply(null, arguments));
}
Expand Down
4 changes: 4 additions & 0 deletions packages/jest-util/src/buffered_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export default class BufferedConsole extends Console {
return buffer;
}

debug() {
BufferedConsole.write(this._buffer, 'debug', format.apply(null, arguments));
}

log() {
BufferedConsole.write(this._buffer, 'log', format.apply(null, arguments));
}
Expand Down
1 change: 1 addition & 0 deletions packages/jest-util/src/null_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Console from './Console';

export default class NullConsole extends Console {
assert() {}
debug() {}
dir() {}
error() {}
info() {}
Expand Down
2 changes: 1 addition & 1 deletion types/Console.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export type LogEntry = {|
origin: string,
type: LogType,
|};
export type LogType = 'log' | 'info' | 'warn' | 'error';
export type LogType = 'debug' | 'log' | 'info' | 'warn' | 'error';
export type ConsoleBuffer = Array<LogEntry>;

0 comments on commit 7f715c8

Please sign in to comment.