Skip to content

Commit

Permalink
[kbn-test] fix junit report test for local run (elastic#198120)
Browse files Browse the repository at this point in the history
## 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 ec72eb2)
  • Loading branch information
dmlemeshko committed Oct 30, 2024
1 parent dcf5007 commit ec9da5a
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 ec9da5a

Please sign in to comment.