-
-
Couldn't load subscription status.
- Fork 6.6k
fix(jest-reporters): print out console log for GHA reporter and group by test file #15864
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
Changes from 5 commits
3eafb97
18d897c
5048ef2
f09cbb9
e2dfd80
96ba394
b1bf034
a386875
49842f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ export default function getConsoleOutput( | |
| globalConfig: Config.GlobalConfig, | ||
| ): string { | ||
| const TITLE_INDENT = | ||
| globalConfig.verbose === true ? ' '.repeat(2) : ' '.repeat(4); | ||
| globalConfig?.verbose === true ? ' '.repeat(2) : ' '.repeat(4); | ||
|
||
| const CONSOLE_INDENT = TITLE_INDENT + ' '.repeat(2); | ||
|
|
||
| const logEntries = buffer.reduce((output, {type, message, origin}) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -687,5 +687,108 @@ describe('logs', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(mockedStderrWrite.mock.calls).toMatchSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test('onTestResult last with console output for failed test', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const mockTest = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rootDir: '/testDir', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const mockTestResult = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: 'bar', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| origin: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ' at Object.log (/tmp/jest-test/a.test.js:2:13)\n at Promise.finally.completed (/github.com/jestjs/jest/packages/jest-circus/build/jestAdapterInit.js:1557:28)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: 'log', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| failureMessage: 'Failure message', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| perfStats: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runtime: 20, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| slow: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testFilePath: '/testDir/test1.js', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testResults: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ancestorTitles: [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| duration: 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: 'passed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: 'test1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const mockResults = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numFailedTestSuites: 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numPassedTestSuites: 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numTotalTestSuites: 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| testResults: [mockTestResult], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const gha = new GitHubActionsReporter({} as Config.GlobalConfig, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| silent: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const makeGlobalConfig = ( | |
| overrides: Partial<Config.GlobalConfig> = {}, | |
| ): Config.GlobalConfig => { | |
| const overridesKeys = new Set(Object.keys(overrides)); | |
| for (const key of Object.keys(DEFAULT_GLOBAL_CONFIG)) { | |
| overridesKeys.delete(key); | |
| } | |
| if (overridesKeys.size > 0) { | |
| throw new Error(` | |
| Properties that are not part of GlobalConfig type were passed: | |
| ${JSON.stringify([...overridesKeys])} | |
| `); | |
| } | |
| return {...DEFAULT_GLOBAL_CONFIG, ...overrides}; | |
| }; | |
| export const makeProjectConfig = ( | |
| overrides: Partial<Config.ProjectConfig> = {}, | |
| ): Config.ProjectConfig => { | |
| const overridesKeys = new Set(Object.keys(overrides)); | |
| for (const key of Object.keys(DEFAULT_PROJECT_CONFIG)) { | |
| overridesKeys.delete(key); | |
| } | |
| if (overridesKeys.size > 0) { | |
| throw new Error(` | |
| Properties that are not part of ProjectConfig type were passed: | |
| ${JSON.stringify([...overridesKeys])} | |
| `); | |
| } | |
| return {...DEFAULT_PROJECT_CONFIG, ...overrides}; | |
| }; |
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.
mind putting the entries alphabetically?