forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure verbose mode prints output synchronously
Fixes jestjs#8208
- Loading branch information
1 parent
24f9bc8
commit 5b8e471
Showing
10 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`console debugging with --verbose 1`] = ``; | ||
|
||
exports[`console debugging with --verbose 2`] = ` | ||
PASS __tests__/console-debugging.test.js | ||
✓ verbose mode prints console output synchronously | ||
`; | ||
|
||
exports[`console debugging with --verbose 3`] = ` | ||
Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 1 passed, 1 total | ||
Time: <<REPLACED>> | ||
Ran all test suites. | ||
`; |
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,23 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {wrap} from 'jest-snapshot-serializer-raw'; | ||
import {extractSummary} from '../Utils'; | ||
import runJest from '../runJest'; | ||
|
||
test('console debugging with --verbose', () => { | ||
const {stderr, stdout, exitCode} = runJest('console-debugging', [ | ||
'--noStackTrace', | ||
'--no-cache', | ||
]); | ||
const {summary, rest} = extractSummary(stderr); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(wrap(stdout)).toMatchSnapshot(); | ||
expect(wrap(rest)).toMatchSnapshot(); | ||
expect(wrap(summary)).toMatchSnapshot(); | ||
}); |
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,24 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const stdoutWrite = require('../stdout-spy'); | ||
|
||
process.stdout.write = jest.fn(process.stdout.write); | ||
|
||
test('verbose mode prints console output synchronously', () => { | ||
console.log('test'); | ||
|
||
expect(stdoutWrite.text).toMatchInlineSnapshot(` | ||
" console.log | ||
test | ||
at Object.log (__tests__/console-debugging.test.js:14:11) | ||
" | ||
`); | ||
}); |
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,6 @@ | ||
require('./stdout-spy'); | ||
|
||
module.exports = { | ||
testEnvironment: 'node', | ||
verbose: true, | ||
}; |
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 @@ | ||
{} |
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,18 @@ | ||
const originalStdoutWrite = process.stdout.write; | ||
|
||
global.process.__stdoutWriteMock = global.process.__stdoutWriteMock || null; | ||
|
||
/* | ||
This is a terrible hack to ensure that we monkeyPath stdoutWrite before | ||
the jest reporter does... | ||
*/ | ||
if (!global.process.__stdoutWriteMock) { | ||
global.process.__stdoutWriteMock = (...args) => { | ||
global.process.__stdoutWriteMock.text = args[0]; | ||
originalStdoutWrite(...args); | ||
}; | ||
|
||
process.stdout.write = global.process.__stdoutWriteMock; | ||
} | ||
|
||
module.exports = global.process.__stdoutWriteMock; |
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
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