Skip to content

Commit

Permalink
[8.x] [kbn-test] fix junit report test for local run (#198120) (#198254)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[kbn-test] fix junit report test for local run
(#198120)](#198120)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-30T08:32:40Z","message":"[kbn-test]
fix junit report test for local run (#198120)\n\n## Summary\r\n\r\nWhen
I run test locally with `node scripts/jest
--config\r\npackages/kbn-test/jest.config.js`, it fails
with\r\n\r\n```\r\n FAIL
packages/kbn-test/src/mocha/junit_report_generation.test.js\r\n ●
dev/mocha/junit report generation › reports on failed setup
hooks\r\n\r\n expect(received).toEqual(expected) // deep
equality\r\n\r\n - Expected - 1\r\n + Received + 1\r\n\r\n @@ -1,7 +1,7
@@\r\n Object {\r\n - \"command-line\": \"node scripts/jest
--config=packages/kbn-test/jest.config.js --runInBand --coverage=false
--passWithNoTests\",\r\n + \"command-line\": \"node
node_modules/jest-worker/build/workers/processChild.js\",\r\n
\"failures\": \"2\",\r\n \"metadata-json\": \"{}\",\r\n \"name\":
\"test\",\r\n \"skipped\": \"1\",\r\n \"tests\":
\"4\",\r\n```\r\n\r\nThis PR uses `process.env.CI` as a condition to
apply different value\r\nfor `command-line` property so test will pass
locally
too.","sha":"ec72eb22239838e58e277d28a8b0faf4d3acff59","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:version","v8.17.0"],"title":"[kbn-test]
fix junit report test for local
run","number":198120,"url":"https://github.com/elastic/kibana/pull/198120","mergeCommit":{"message":"[kbn-test]
fix junit report test for local run (#198120)\n\n## Summary\r\n\r\nWhen
I run test locally with `node scripts/jest
--config\r\npackages/kbn-test/jest.config.js`, it fails
with\r\n\r\n```\r\n FAIL
packages/kbn-test/src/mocha/junit_report_generation.test.js\r\n ●
dev/mocha/junit report generation › reports on failed setup
hooks\r\n\r\n expect(received).toEqual(expected) // deep
equality\r\n\r\n - Expected - 1\r\n + Received + 1\r\n\r\n @@ -1,7 +1,7
@@\r\n Object {\r\n - \"command-line\": \"node scripts/jest
--config=packages/kbn-test/jest.config.js --runInBand --coverage=false
--passWithNoTests\",\r\n + \"command-line\": \"node
node_modules/jest-worker/build/workers/processChild.js\",\r\n
\"failures\": \"2\",\r\n \"metadata-json\": \"{}\",\r\n \"name\":
\"test\",\r\n \"skipped\": \"1\",\r\n \"tests\":
\"4\",\r\n```\r\n\r\nThis PR uses `process.env.CI` as a condition to
apply different value\r\nfor `command-line` property so test will pass
locally
too.","sha":"ec72eb22239838e58e277d28a8b0faf4d3acff59"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198120","number":198120,"mergeCommit":{"message":"[kbn-test]
fix junit report test for local run (#198120)\n\n## Summary\r\n\r\nWhen
I run test locally with `node scripts/jest
--config\r\npackages/kbn-test/jest.config.js`, it fails
with\r\n\r\n```\r\n FAIL
packages/kbn-test/src/mocha/junit_report_generation.test.js\r\n ●
dev/mocha/junit report generation › reports on failed setup
hooks\r\n\r\n expect(received).toEqual(expected) // deep
equality\r\n\r\n - Expected - 1\r\n + Received + 1\r\n\r\n @@ -1,7 +1,7
@@\r\n Object {\r\n - \"command-line\": \"node scripts/jest
--config=packages/kbn-test/jest.config.js --runInBand --coverage=false
--passWithNoTests\",\r\n + \"command-line\": \"node
node_modules/jest-worker/build/workers/processChild.js\",\r\n
\"failures\": \"2\",\r\n \"metadata-json\": \"{}\",\r\n \"name\":
\"test\",\r\n \"skipped\": \"1\",\r\n \"tests\":
\"4\",\r\n```\r\n\r\nThis PR uses `process.env.CI` as a condition to
apply different value\r\nfor `command-line` property so test will pass
locally
too.","sha":"ec72eb22239838e58e277d28a8b0faf4d3acff59"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Dzmitry Lemechko <[email protected]>
  • Loading branch information
kibanamachine and dmlemeshko authored Nov 11, 2024
1 parent dc44d7c commit 3b033b4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/kbn-test/src/mocha/junit_report_generation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3b033b4

Please sign in to comment.