From ec9da5a5aec6ef8aca422fa95964fb511bb119fe Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 30 Oct 2024 09:32:40 +0100 Subject: [PATCH] [kbn-test] fix junit report test for local run (#198120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary When I run test locally with `node scripts/jest --config packages/kbn-test/jest.config.js`, it fails with ``` FAIL packages/kbn-test/src/mocha/junit_report_generation.test.js ● dev/mocha/junit report generation › reports on failed setup hooks expect(received).toEqual(expected) // deep equality - Expected - 1 + Received + 1 @@ -1,7 +1,7 @@ Object { - "command-line": "node scripts/jest --config=packages/kbn-test/jest.config.js --runInBand --coverage=false --passWithNoTests", + "command-line": "node node_modules/jest-worker/build/workers/processChild.js", "failures": "2", "metadata-json": "{}", "name": "test", "skipped": "1", "tests": "4", ``` This PR uses `process.env.CI` as a condition to apply different value for `command-line` property so test will pass locally too. (cherry picked from commit ec72eb22239838e58e277d28a8b0faf4d3acff59) --- .../kbn-test/src/mocha/junit_report_generation.test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/kbn-test/src/mocha/junit_report_generation.test.js b/packages/kbn-test/src/mocha/junit_report_generation.test.js index caf023a795154..6dbc8bf6cf1f8 100644 --- a/packages/kbn-test/src/mocha/junit_report_generation.test.js +++ b/packages/kbn-test/src/mocha/junit_report_generation.test.js @@ -55,9 +55,12 @@ describe('dev/mocha/junit report generation', () => { const [testsuite] = report.testsuites.testsuite; expect(testsuite.$.time).toMatch(DURATION_REGEX); expect(testsuite.$.timestamp).toMatch(ISO_DATE_SEC_REGEX); - expect(testsuite.$).toEqual({ - 'command-line': - 'node scripts/jest --config=packages/kbn-test/jest.config.js --runInBand --coverage=false --passWithNoTests', + const expectedCommandLine = process.env.CI + ? 'node scripts/jest --config=packages/kbn-test/jest.config.js --runInBand --coverage=false --passWithNoTests' + : 'node node_modules/jest-worker/build/workers/processChild.js'; + + expect(testsuite.$).toMatchObject({ + 'command-line': expectedCommandLine, failures: '2', name: 'test', skipped: '1',