Skip to content
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

Add "debug" method to console #5350

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;