-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
getConsoleOutput receives global noStackTrace #10081
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
91165d3
getConsoleOutput receives global noStackTrace
ychi ce2ae46
linting
ychi 26b1aef
changelog
ychi 67d62f7
lint
ychi 102e7fb
this test case actually tests formatStackTrace
ychi ccc2e4c
prettier
ychi ed13e4d
snapshot update
ychi e5783a3
getConsoleOutput to depend on GlobalConfig
ychi 01a89c3
integration test for noStackTrace
ychi 28b8337
optional global config
ychi 5caa72e
review feedbacks
ychi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
57 changes: 57 additions & 0 deletions
57
packages/jest-console/src/__tests__/getConsoleOutput.test.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,57 @@ | ||
/** | ||
* 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 {formatStackTrace} from 'jest-message-util'; | ||
import getConsoleOutput from '../getConsoleOutput'; | ||
import BufferedConsole from '../BufferedConsole'; | ||
import type {LogType} from '../types'; | ||
import {makeGlobalConfig} from '../../../../TestUtils'; | ||
|
||
jest.mock('jest-message-util', () => ({ | ||
formatStackTrace: jest.fn(), | ||
})); | ||
|
||
describe('getConsoleOutput', () => { | ||
const globalConfig = makeGlobalConfig({noStackTrace: true}); | ||
formatStackTrace.mockImplementation(() => 'throw new Error("Whoops!");'); | ||
|
||
it.each` | ||
logType | ||
${'assert'} | ||
${'count'} | ||
${'debug'} | ||
${'dir'} | ||
${'dirxml'} | ||
${'error'} | ||
${'group'} | ||
${'groupCollapsed'} | ||
${'info'} | ||
${'log'} | ||
${'time'} | ||
${'warn'} | ||
`('takes noStackTrace and pass it on for $logType', logType => { | ||
getConsoleOutput( | ||
'someRootPath', | ||
true, | ||
BufferedConsole.write([], logType as LogType, 'message', 4), | ||
{ | ||
rootDir: 'root', | ||
testMatch: [], | ||
}, | ||
globalConfig, | ||
); | ||
expect(formatStackTrace).toHaveBeenCalled(); | ||
expect(formatStackTrace).toHaveBeenCalledWith( | ||
expect.anything(), | ||
expect.anything(), | ||
expect.objectContaining({ | ||
noCodeFrame: expect.anything(), | ||
noStackTrace: 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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed 26, I can follow closer and create PR when 27 is near.