Skip to content

[scout] Add Jest events reporter#214662

Merged
dolaru merged 27 commits intoelastic:mainfrom
dolaru:scout-jest-reporter
Apr 3, 2025
Merged

[scout] Add Jest events reporter#214662
dolaru merged 27 commits intoelastic:mainfrom
dolaru:scout-jest-reporter

Conversation

@dolaru
Copy link
Copy Markdown
Contributor

@dolaru dolaru commented Mar 14, 2025

Summary

Same as for Playwright, this adds a custom Jest reporter that records and uploads test events.

Quirks

Config file path

Jest is not including the path to the config file used to run the tests in any information passed to the reporter, so this needs to be passed in the JEST_CONFIG_PATH environment variable. If Jest is invoked with the scripts/jest.js script, the JEST_CONFIG_PATH environment variable will be populated with the correct value automatically.

All the events are produced when the run has completed

This is different from the other reporters because the custom reporter interface in Jest is giving the reporter access to necessary info at init or when the run starts. The earliest we can start producing the Scout events is, unfortunately, only after the test run has completed.

Same as for Playwright, this adds a custom Jest reporter that records and uploads test events.
@dolaru dolaru self-assigned this Mar 14, 2025
@dolaru dolaru added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.1.0 v8.19.0 v9.0.1 test:scout labels Mar 14, 2025
@dolaru dolaru marked this pull request as ready for review March 19, 2025 12:06
@dolaru dolaru requested review from a team as code owners March 19, 2025 12:06
Copy link
Copy Markdown
Contributor

@wayneseymour wayneseymour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question or two, but looks good. Ran it on my machine and I see that it did not upload, as it should not, but did record the results to .scout/reports/scout-jest-075d4121641ca89a/event-log.ndjson

Copy link
Copy Markdown
Contributor

@jbudz jbudz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jest-preset changes LGTM.

I'm out of the loop on where we're headed with the testing changes and am probably not the best source to review. I can do a closer look on specifics if needed but need to get up to speed on the background.

This will produce a decent amount of data, may be worth considering a gradual rollout.

Copy link
Copy Markdown
Member

@csr csr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR!

@dolaru dolaru requested a review from pheyos April 2, 2025 15:38
@dolaru
Copy link
Copy Markdown
Contributor Author

dolaru commented Apr 2, 2025

I noticed one thing - it seems like we're not stripping the ANSI color codes from the error message or stack trace. This makes these two fields hard(er) to read.

@csr Resolved in 78f6a9e

@csr
Copy link
Copy Markdown
Member

csr commented Apr 2, 2025

Following up - the color stripping is working well on my side! 👏 thanks!

jest-reporter-pr-strip-color-code

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @dolaru

Copy link
Copy Markdown
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@dolaru dolaru merged commit 563c7c3 into elastic:main Apr 3, 2025
10 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.x, 9.0

https://github.com/elastic/kibana/actions/runs/14250021909

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 3, 2025
## Summary

Same as for Playwright, this adds a custom Jest reporter that records
and uploads test events.

## Quirks

### Config file path
Jest is not including the path to the config file used to run the tests
in any information passed to the reporter, so this needs to be passed in
the `JEST_CONFIG_PATH` environment variable. If Jest is invoked with the
`scripts/jest.js` script, the `JEST_CONFIG_PATH` environment variable
will be populated with the correct value automatically.

### All the events are produced when the run has completed
This is different from the other reporters because the custom reporter
interface in Jest is giving the reporter access to necessary info at
init or when the run starts. The earliest we can start producing the
Scout events is, unfortunately, only after the test run has completed.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Cesare de Cal <cesare.decal@elastic.co>
(cherry picked from commit 563c7c3)
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 3, 2025
## Summary

Same as for Playwright, this adds a custom Jest reporter that records
and uploads test events.

## Quirks

### Config file path
Jest is not including the path to the config file used to run the tests
in any information passed to the reporter, so this needs to be passed in
the `JEST_CONFIG_PATH` environment variable. If Jest is invoked with the
`scripts/jest.js` script, the `JEST_CONFIG_PATH` environment variable
will be populated with the correct value automatically.

### All the events are produced when the run has completed
This is different from the other reporters because the custom reporter
interface in Jest is giving the reporter access to necessary info at
init or when the run starts. The earliest we can start producing the
Scout events is, unfortunately, only after the test run has completed.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Cesare de Cal <cesare.decal@elastic.co>
(cherry picked from commit 563c7c3)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.x
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 3, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [[scout] Add Jest events reporter
(#214662)](#214662)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"David
Olaru","email":"dolaru@elastic.co"},"sourceCommit":{"committedDate":"2025-04-03T18:20:33Z","message":"[scout]
Add Jest events reporter (#214662)\n\n## Summary\n\nSame as for
Playwright, this adds a custom Jest reporter that records\nand uploads
test events.\n\n## Quirks\n\n### Config file path\nJest is not including
the path to the config file used to run the tests\nin any information
passed to the reporter, so this needs to be passed in\nthe
`JEST_CONFIG_PATH` environment variable. If Jest is invoked with
the\n`scripts/jest.js` script, the `JEST_CONFIG_PATH` environment
variable\nwill be populated with the correct value automatically.\n\n###
All the events are produced when the run has completed\nThis is
different from the other reporters because the custom
reporter\ninterface in Jest is giving the reporter access to necessary
info at\ninit or when the run starts. The earliest we can start
producing the\nScout events is, unfortunately, only after the test run
has completed.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Cesare de Cal
<cesare.decal@elastic.co>","sha":"563c7c3388bcef479a45ea69b45e4236822c8703","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","test:scout","v9.1.0","v8.19.0","v9.0.1"],"title":"[scout]
Add Jest events
reporter","number":214662,"url":"https://github.com/elastic/kibana/pull/214662","mergeCommit":{"message":"[scout]
Add Jest events reporter (#214662)\n\n## Summary\n\nSame as for
Playwright, this adds a custom Jest reporter that records\nand uploads
test events.\n\n## Quirks\n\n### Config file path\nJest is not including
the path to the config file used to run the tests\nin any information
passed to the reporter, so this needs to be passed in\nthe
`JEST_CONFIG_PATH` environment variable. If Jest is invoked with
the\n`scripts/jest.js` script, the `JEST_CONFIG_PATH` environment
variable\nwill be populated with the correct value automatically.\n\n###
All the events are produced when the run has completed\nThis is
different from the other reporters because the custom
reporter\ninterface in Jest is giving the reporter access to necessary
info at\ninit or when the run starts. The earliest we can start
producing the\nScout events is, unfortunately, only after the test run
has completed.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Cesare de Cal
<cesare.decal@elastic.co>","sha":"563c7c3388bcef479a45ea69b45e4236822c8703"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214662","number":214662,"mergeCommit":{"message":"[scout]
Add Jest events reporter (#214662)\n\n## Summary\n\nSame as for
Playwright, this adds a custom Jest reporter that records\nand uploads
test events.\n\n## Quirks\n\n### Config file path\nJest is not including
the path to the config file used to run the tests\nin any information
passed to the reporter, so this needs to be passed in\nthe
`JEST_CONFIG_PATH` environment variable. If Jest is invoked with
the\n`scripts/jest.js` script, the `JEST_CONFIG_PATH` environment
variable\nwill be populated with the correct value automatically.\n\n###
All the events are produced when the run has completed\nThis is
different from the other reporters because the custom
reporter\ninterface in Jest is giving the reporter access to necessary
info at\ninit or when the run starts. The earliest we can start
producing the\nScout events is, unfortunately, only after the test run
has completed.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Cesare de Cal
<cesare.decal@elastic.co>","sha":"563c7c3388bcef479a45ea69b45e4236822c8703"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: David Olaru <dolaru@elastic.co>
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Apr 7, 2025
kibanamachine added a commit that referenced this pull request Apr 8, 2025
# Backport

This will backport the following commits from `main` to `9.0`:
- [[scout] Add Jest events reporter
(#214662)](#214662)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"David
Olaru","email":"dolaru@elastic.co"},"sourceCommit":{"committedDate":"2025-04-03T18:20:33Z","message":"[scout]
Add Jest events reporter (#214662)\n\n## Summary\n\nSame as for
Playwright, this adds a custom Jest reporter that records\nand uploads
test events.\n\n## Quirks\n\n### Config file path\nJest is not including
the path to the config file used to run the tests\nin any information
passed to the reporter, so this needs to be passed in\nthe
`JEST_CONFIG_PATH` environment variable. If Jest is invoked with
the\n`scripts/jest.js` script, the `JEST_CONFIG_PATH` environment
variable\nwill be populated with the correct value automatically.\n\n###
All the events are produced when the run has completed\nThis is
different from the other reporters because the custom
reporter\ninterface in Jest is giving the reporter access to necessary
info at\ninit or when the run starts. The earliest we can start
producing the\nScout events is, unfortunately, only after the test run
has completed.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Cesare de Cal
<cesare.decal@elastic.co>","sha":"563c7c3388bcef479a45ea69b45e4236822c8703","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","test:scout","v9.1.0","v8.19.0","v9.0.1"],"title":"[scout]
Add Jest events
reporter","number":214662,"url":"https://github.com/elastic/kibana/pull/214662","mergeCommit":{"message":"[scout]
Add Jest events reporter (#214662)\n\n## Summary\n\nSame as for
Playwright, this adds a custom Jest reporter that records\nand uploads
test events.\n\n## Quirks\n\n### Config file path\nJest is not including
the path to the config file used to run the tests\nin any information
passed to the reporter, so this needs to be passed in\nthe
`JEST_CONFIG_PATH` environment variable. If Jest is invoked with
the\n`scripts/jest.js` script, the `JEST_CONFIG_PATH` environment
variable\nwill be populated with the correct value automatically.\n\n###
All the events are produced when the run has completed\nThis is
different from the other reporters because the custom
reporter\ninterface in Jest is giving the reporter access to necessary
info at\ninit or when the run starts. The earliest we can start
producing the\nScout events is, unfortunately, only after the test run
has completed.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Cesare de Cal
<cesare.decal@elastic.co>","sha":"563c7c3388bcef479a45ea69b45e4236822c8703"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214662","number":214662,"mergeCommit":{"message":"[scout]
Add Jest events reporter (#214662)\n\n## Summary\n\nSame as for
Playwright, this adds a custom Jest reporter that records\nand uploads
test events.\n\n## Quirks\n\n### Config file path\nJest is not including
the path to the config file used to run the tests\nin any information
passed to the reporter, so this needs to be passed in\nthe
`JEST_CONFIG_PATH` environment variable. If Jest is invoked with
the\n`scripts/jest.js` script, the `JEST_CONFIG_PATH` environment
variable\nwill be populated with the correct value automatically.\n\n###
All the events are produced when the run has completed\nThis is
different from the other reporters because the custom
reporter\ninterface in Jest is giving the reporter access to necessary
info at\ninit or when the run starts. The earliest we can start
producing the\nScout events is, unfortunately, only after the test run
has completed.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Cesare de Cal
<cesare.decal@elastic.co>","sha":"563c7c3388bcef479a45ea69b45e4236822c8703"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: David Olaru <dolaru@elastic.co>
@kibanamachine kibanamachine added v9.0.0 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Apr 8, 2025
@mistic mistic removed the v9.0.1 label Apr 15, 2025
@dolaru dolaru deleted the scout-jest-reporter branch May 28, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes test:scout v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants