- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- 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
          
     Merged
      
      
            SimenB
  merged 9 commits into
  jestjs:main
from
hainenber:fix/gha-reporter-not-print-out-console-output
  
      
      
   
  Oct 27, 2025 
      
    
      
        
          +218
        
        
          −21
        
        
          
        
      
    
  
  
     Merged
                    Changes from 1 commit
      Commits
    
    
            Show all changes
          
          
            9 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      3eafb97
              
                fix(jest-reporters): print out console log for GHA reporter and group…
              
              
                hainenber 18d897c
              
                chore: add CHANGELOG entry
              
              
                hainenber 5048ef2
              
                chore: resolve lint issue
              
              
                hainenber f09cbb9
              
                Merge branch 'main' into fix/gha-reporter-not-print-out-console-output
              
              
                hainenber e2dfd80
              
                Merge branch 'main' into fix/gha-reporter-not-print-out-console-output
              
              
                hainenber 96ba394
              
                Apply suggestion from @SimenB
              
              
                hainenber b1bf034
              
                Apply suggestion from @SimenB
              
              
                hainenber a386875
              
                chore: resolve SimonB's comments
              
              
                hainenber 49842f2
              
                use helper in all tests
              
              
                SimenB 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 hidden or 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 hidden or 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 hidden or 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|  | @@ -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}; | |
| }; | 
  
    
      This file contains hidden or 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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  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.
I have to add
verbosenullish check for double assuranceThere 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.
when is it missing? types says it shouldn't be
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.
My bad, I was doing nullish check on
globalConfiginstead 😮💨 . Will revert in next revision.