-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
feat: add long test time threshold option #9366
feat: add long test time threshold option #9366
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9366 +/- ##
==========================================
+ Coverage 64.77% 64.79% +0.02%
==========================================
Files 280 280
Lines 11987 11988 +1
Branches 2956 2955 -1
==========================================
+ Hits 7764 7768 +4
Misses 3591 3591
+ Partials 632 629 -3
Continue to review full report at Codecov.
|
Thanks for the PR! Can we make this a reporter option instead? |
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.
Let's discuss it a bit more
@@ -46,7 +46,7 @@ export default ( | |||
: null; | |||
|
|||
const testDetail = []; | |||
if (runTime !== null && runTime > 5) { | |||
if (runTime !== null && runTime > globalConfig.longTestThreshold) { |
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.
As OP from the mentioned issue said, such config option makes sense for specific scenarios (like running e2e tests), or in Jest nomenclature "projects". Hence, putting it into globalConfig
is not the best place.
I'd go with either putting this inside projectConfig
or making it an option of a reporter as @SimenB suggested. I'm not 100% convinced where the responsibility lies, but for now I'd expect Jest to determine whether the test was slow and pass that information to the reporter to render, so I'm leaning towards projectConfig
solution.
d5aa73c
to
b0ba242
Compare
In hindsight |
Hey @Draco-Umbratilis, great job with this feature. Looks like there's some interest from @SimenB to get this merged in. Are you able to get this branch updated and pushed across the finish line, or do you want a hand with the last bit? Lemme know as we're keen to get this merged in and used in our project, but I don't want to step on your toes here. Thanks! |
Hi @joshuapinter, I will try to update the branch later today. Lets see whether someone (@SimenB @thymikee ?) will have some more notes after that or not. |
👍 Beauty. Looks like you've done a great job with it. |
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.
Forgot about this! 😅 I don't feel too strongly about making it a reporter option (mostly because it's sorta finicky as we have some magic around setting default reporters which might mess up here)
@@ -259,7 +259,12 @@ async function runTestInternal( | |||
result.numPendingTests + | |||
result.numTodoTests; | |||
|
|||
result.perfStats = {end: Date.now(), start}; | |||
const end = Date.now(); | |||
result.perfStats = { |
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.
should we stick runtime
or something on here as well so we don't have to do end-start
in multiple places?
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.
@Draco-Umbratilis just this comment and we should be good to go
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 found one occurrence in jest-test-sequencer and made the change also there. Reflected in tests and changelog, I hope it is ok.
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.
Yeah, I like it!
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
99ad223
to
e2a4d28
Compare
packages/jest-cli/src/init/__tests__/__snapshots__/init.test.js.snap
Outdated
Show resolved
Hide resolved
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
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.
Thanks!
Nice job @SimenB and @Draco-Umbratilis! Thank you! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Adds
slowTestThreshold
option to configure what is considered to be a long running test. Defaults to 5 seconds since it was the original hardcoded value. Based on suggestions from #7220.Fixes #7220
Test plan
I have added two new tests to
get_result_header.test.js
.