@@ -9,11 +9,19 @@ const jestValidate = require('jest-validate');
99const buildJsonResults = require ( './utils/buildJsonResults' ) ;
1010const getOptions = require ( './utils/getOptions' ) ;
1111
12+ // Store console results from onTestResult to later
13+ // append to result
14+ const consoleBuffer = { } ;
15+
1216const processor = ( report , reporterOptions = { } , jestRootDir = null ) => {
1317 // If jest-junit is used as a reporter allow for reporter options
1418 // to be used. Env and package.json will override.
1519 const options = getOptions . options ( reporterOptions ) ;
1620
21+ report . testResults . forEach ( ( t , i ) => {
22+ t . console = consoleBuffer [ t . testFilePath ] ;
23+ } ) ;
24+
1725 const jsonResults = buildJsonResults ( report , fs . realpathSync ( process . cwd ( ) ) , options ) ;
1826
1927 // Set output to use new outputDirectory and fallback on original output
@@ -64,6 +72,12 @@ function JestJUnit (globalConfig, options) {
6472 this . _globalConfig = globalConfig ;
6573 this . _options = options ;
6674
75+ this . onTestResult = ( test , testResult , aggregatedResult ) => {
76+ if ( testResult . console && testResult . console . length > 0 ) {
77+ consoleBuffer [ testResult . testFilePath ] = testResult . console ;
78+ }
79+ } ;
80+
6781 this . onRunComplete = ( contexts , results ) => {
6882 processor ( results , this . _options , this . _globalConfig . rootDir ) ;
6983 } ;
0 commit comments