-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enterprise Search] Jest config & handy Jest script #84839
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks for making our lives easier!
🎉 🎉 🎉
Just a heads up, I am working on a global runner which I believe will solve some of the things you're doing here. My WIP is here: #84848 But essentially it will update |
Oooh!! Thanks so much Tyler! 🎉 I can definitely hang tight on this PR until yours is merged in and play around with that.
Fantastic, this would be amazing! I've had some issues recently with |
Sounds great! Yeah, it should remove the need for the |
b747758
to
e59cc67
Compare
17c6fe2
to
93c6631
Compare
@tylersmalley The command works fantastic for only running tests within the current folder/subdir, but unfortunately I couldn't get the new Unfortunately current behavior for running I opted to keep using the |
- No more super intricate yarn commands! Hooray
…rs/subdirectories
93c6631
to
6e947d8
Compare
💚 Build SucceededMetrics [docs]Distributable file count
History
To update your PR or re-run it, just comment with: |
@@ -8,4 +8,11 @@ module.exports = { | |||
preset: '@kbn/test', | |||
rootDir: '../../..', | |||
roots: ['<rootDir>/x-pack/plugins/enterprise_search'], | |||
collectCoverage: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you want to enable coverage by default. In your jest.sh file you can pass --coveage
to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, from a team perspective I'd prefer it for this project - coverage is fairly important to us and something I want our front end devs to always have in front of them.
If this has implications for CI or affects processes outside just our team/code though I can definitely turn it off and only set it in jest.sh
- if not, I'd prefer to leave it as the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the importance of code coverage. While it won't have an impact on CI it does impact the default experience of anyone running yarn jest:test
within the plugin. It will by default include code coverage for the entire plugin which requires a lot of scrolling to get to the normal output.
I will note that we are working on having code coverage reports/metrics as part of the pull request details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it won't have an impact on CI it does impact the default experience of anyone running yarn jest:test within the plugin
This should mostly be just Enterprise Search frontend devs though, right? In which case our team would fully expect this behavior. Is the concern for other non-Enterprise Search devs who need to make changes to our files/repo? (e.g., Kibana ops, etc.) That's definitely valid if so, but I would argue that it's a minor nuisance at worst for non-Enterprise Search devs who rarely need to make changes / run tests directly on our repo, but it's a major quality of life default for Enterprise Search devs since we're working on our code constantly and essentially always want to see accompanying coverage %s when we're running tests.
I will note that we are working on having code coverage reports/metrics as part of the pull request details.
Oh wow, that's amazing! I love developing on the Kibana platform so much, y'all just continue to be blow me away 🎉 Just curious, will the code coverage report for the touched files in the PR only, or reported based on the nearest jest config file (i.e. the entire plugin)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should mostly be just Enterprise Search frontend devs though, right? In which case our team would fully expect this behavior. Is the concern for other non-Enterprise Search devs who need to make changes to our files/repo? (e.g., Kibana ops, etc.) That's definitely valid if so, but I would argue that it's a minor nuisance at worst for non-Enterprise Search devs who rarely need to make changes / run tests directly on our repo, but it's a major quality of life default for Enterprise Search devs since we're working on our code constantly and essentially always want to see accompanying coverage %s when we're running tests.
Sounds like you have thought it through. I was just raising to make sure you're aware and sounds like this is what you expect. 👍
Oh wow, that's amazing! I love developing on the Kibana platform so much, y'all just continue to be blow me away tada Just curious, will the code coverage report for the touched files in the PR only, or reported based on the nearest jest config file (i.e. the entire plugin)?
It will be for the touched files. I really feel that is where the value of a code coverage report comes in, and it must be available at review time. The first step of this is to include the change as part of the metrics. However, we intend to iterate on this over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be for the touched files. I really feel that is where the value of a code coverage report comes in, and it must be available at review time.
Love it, that's totally what I was hoping for! Can't wait to see it happen, I'll definitely owe you some beers at the next all hands (whenever that is, haha 🍻 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
95% of the time that I'm running jest it's with the --watch
flag, in which case, I do not need coverage reports, and probably don't want them to be run if it slows down the speed for tests. Do you know what effect this has on that use case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JasonStoltz With --watch
on, it reports coverage for only the file that you touched:
That was on a server ts file, when I made changes on a Kea logic file and on a component tsx file, I saw some different/odd behavior (all 0s) but still nothing (IMO) that would significantly affect speed since coverage was still only being reported for 1 file vs the entire plugin.
I'm going to go ahead and merge this plugin in now as a heads up since it's been open a while - if you see significant performance issues due to text coverage reports, definitely let me know and we can continue to adjust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, well that is actually really rad if it only reports coverage on the file you touched. That's a big plus. I was seeing different behavior when I tried it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's different now with Tyler's changes + (perhaps?) the jest config changes in this PR - definitely feel free to ping if you you see otherwise locally on latest master!
@@ -8,4 +8,11 @@ module.exports = { | |||
preset: '@kbn/test', | |||
rootDir: '../../..', | |||
roots: ['<rootDir>/x-pack/plugins/enterprise_search'], | |||
collectCoverage: true, | |||
coverageReporters: ['text'], | |||
collectCoverageFrom: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing this through the CLI will overwrite this setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right yeah, overriding this setting via CLI is intentional for reporting specific folder coverage. Do you see that as being an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to point it out to make sure it's not being set if it's not intentionally used. Setting it here does deviate from the defaults of the preset defined here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, nice - I really like those presets, I wonder if there's any easy way to merge those in here 🤔 This collectCoverageFrom
is being intentionally used here, essentially what I wanted was to to skip reporting for our public/plugin.ts
and server/plugin.ts
files (AFAIK there's no real meaningful way to write unit tests for those files, correct me if I'm wrong).
@constancecchen, thanks for the clairification. I believe this is something we could add to our wrapper. It does get a bit complicated as we will need to merge in the coverage settings from the project config or the jest-preset but it could be done. Mind creating an issue for it so we can track? |
Yes, no problem at all! Here it is: #86199 No rush on it as well, I'm personally super happy with the existing |
Summary
Let me know what you think y'all!! 🙇♀️
Checklist