-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 #8208
- Loading branch information
1 parent
98ed700
commit 02de105
Showing
7 changed files
with
109 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
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,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. | ||
*/ | ||
'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,9 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node", | ||
"verbose": true, | ||
"setupFiles": [ | ||
"./stdout-spy.js" | ||
] | ||
} | ||
} |
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,10 @@ | ||
const originalStdoutWrite = process.stdout.write; | ||
|
||
const stdoutWrite = (...args) => { | ||
stdoutWrite.text = args[0]; | ||
originalStdoutWrite(...args); | ||
}; | ||
|
||
process.stdout.write = stdoutWrite; | ||
|
||
module.exports = stdoutWrite; |
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