-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gatsby-cli): Address an issue that caused empty logs to print und…
…efined (#23000) * fix(gatsby-cli): Address an issue that caused empty logs to print undefined * fix lint
- Loading branch information
1 parent
ec80671
commit be85f2e
Showing
3 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/gatsby-cli/src/reporter/__tests__/patch-console.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { patchConsole } from "../patch-console" | ||
import { reporter as gatsbyReporter } from "../reporter" | ||
|
||
describe(`patchConsole`, () => { | ||
const reporter = { | ||
log: jest.fn(), | ||
} | ||
patchConsole((reporter as unknown) as typeof gatsbyReporter) | ||
|
||
beforeEach(reporter.log.mockReset) | ||
|
||
it(`handles an empty call`, () => { | ||
console.log() | ||
|
||
// intentionally empty arguments | ||
expect(reporter.log).toBeCalledWith() | ||
}) | ||
|
||
it(`handles multiple arguments`, () => { | ||
console.log(`foo`, `bar`, `baz`) | ||
|
||
expect(reporter.log).toBeCalledWith(`foo bar baz`) | ||
}) | ||
|
||
it(`handles formatting`, () => { | ||
console.log(`%s %d`, `bar`, true) | ||
|
||
expect(reporter.log).toBeCalledWith(`bar 1`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters