From acae05d15a87f16b9c1780dca838158f621cdc30 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 8 Jul 2021 10:02:34 -0700 Subject: [PATCH 1/4] ensure that Jest Integration tests are producing JUnit correctly --- .../src/integration_tests/basic_optimization.test.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts b/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts index 97a7f33be673d..1036de2aa4d1d 100644 --- a/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts +++ b/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts @@ -102,10 +102,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => { assert('produce one worker started event', workerStarted.length === 1); const runningStates = msgs.filter((msg) => msg.state.phase === 'running'); - assert( - 'produce three to five "running" states', - runningStates.length >= 3 && runningStates.length <= 5 - ); + assert('produce three to five "running" states', runningStates.length > 10); const bundleNotCachedEvents = msgs.filter((msg) => msg.event?.type === 'bundle not cached'); assert('produce three "bundle not cached" events', bundleNotCachedEvents.length === 3); From 7cecb133cb9edd32885b47c95dc61d3989c8c267 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 8 Jul 2021 12:19:03 -0700 Subject: [PATCH 2/4] write junit path because that report isn't getting found --- packages/kbn-test/src/jest/junit_reporter.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/kbn-test/src/jest/junit_reporter.ts b/packages/kbn-test/src/jest/junit_reporter.ts index eb5828120a57b..6e2d1001ea2fe 100644 --- a/packages/kbn-test/src/jest/junit_reporter.ts +++ b/packages/kbn-test/src/jest/junit_reporter.ts @@ -106,6 +106,9 @@ export default class JestJUnitReporter extends BaseReporter { const reportPath = getUniqueJunitReportPath(rootDirectory, reportName); const reportXML = root.end(); + + process.stdout.write(`\nWriting Jest JUnit report to [${reportXML}]\n\n`); + mkdirSync(dirname(reportPath), { recursive: true }); writeFileSync(reportPath, reportXML, 'utf8'); } From efd2c17a6abb684a334778d6ffb535bcaef839e6 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 8 Jul 2021 15:12:23 -0700 Subject: [PATCH 3/4] =?UTF-8?q?print=20the=20path,=20not=20the=20report=20?= =?UTF-8?q?=F0=9F=A4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/kbn-test/src/jest/junit_reporter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-test/src/jest/junit_reporter.ts b/packages/kbn-test/src/jest/junit_reporter.ts index 6e2d1001ea2fe..b9d02a735d481 100644 --- a/packages/kbn-test/src/jest/junit_reporter.ts +++ b/packages/kbn-test/src/jest/junit_reporter.ts @@ -107,7 +107,7 @@ export default class JestJUnitReporter extends BaseReporter { const reportPath = getUniqueJunitReportPath(rootDirectory, reportName); const reportXML = root.end(); - process.stdout.write(`\nWriting Jest JUnit report to [${reportXML}]\n\n`); + process.stdout.write(`\nWriting Jest JUnit report to [${reportPath}]\n\n`); mkdirSync(dirname(reportPath), { recursive: true }); writeFileSync(reportPath, reportXML, 'utf8'); From 0e563a300fda694d8107b3380831105be1310d30 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 8 Jul 2021 17:25:59 -0700 Subject: [PATCH 4/4] try specifying the rootDirectory --- jest.config.integration.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jest.config.integration.js b/jest.config.integration.js index 8ff142714eebf..6ae0a617608d4 100644 --- a/jest.config.integration.js +++ b/jest.config.integration.js @@ -7,6 +7,7 @@ */ const preset = require('@kbn/test/jest-preset'); +const { REPO_ROOT } = require('@kbn/dev-utils'); module.exports = { preset: '@kbn/test', @@ -21,7 +22,13 @@ module.exports = { ], reporters: [ 'default', - ['@kbn/test/target_node/jest/junit_reporter', { reportName: 'Jest Integration Tests' }], + [ + '@kbn/test/target_node/jest/junit_reporter', + { + reportName: 'Jest Integration Tests', + rootDirectory: REPO_ROOT, + }, + ], ], coverageReporters: !!process.env.CI ? [['json', { file: 'jest-integration.json' }]]