-
-
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.
getConsoleOutput receives global noStackTrace (#10081)
- Loading branch information
Showing
9 changed files
with
195 additions
and
23 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
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