Provide a custom way to set the thresholds for when the time in the logged output is highlighted (red, for example, when a suite/test takes a long time).
Even a way to turn these warning colors off would be useful.
Some tests are known to take a long time (e.g. spinning up databases, testing database operations), and it'd be nice to not be warned with those colors when running tests.
In the config, some options like timeWarningThreshold where the user could specify the threshold themselves. Or, disabledTimeWarnings to turn them off completely.
I use jest to drive selenium tests and it reports a test that takes 12 seconds as being slow (the duration is highlighted in red). In this context 12 seconds is fine.
In jest.config.js I'd like an option to change the default
slowTestDurationThreshold: 30
The value is hardcoded at 5 seconds at the moment. https://github.com/facebook/jest/blob/b4897796bcbcb972234ef699b3e9e0f6b8724132/packages/jest-reporters/src/get_result_header.js#L44-L46
https://stackoverflow.com/questions/54893177/jest-threshold-for-a-test-to-be-reported-as-slow
I use jest for API tests, where I do actual calls to a running API etc (sometimes simulating entire flows). In that case it would also be helpful to define a custom threshold.
Same here. My e2e API tests are much slower and need to be able to set a different threshold. Just like with Mocha.
we would like this feature too!
Us too. We use Appium for e2e testing and it takes longer than 5 seconds just to spin up the app.
If a contributor could comment on if they would be open to a PR that would make this configurable, we would be happy to create a PR for it.
Thanks.
PR welcome! While the threshold works for unit tests, it might not make sense for e.g. integrations tests.
Make sure to add it to ProjectConfig.
@SimenB Thanks for the response, Simen. I was just about to fork this but it looks like @Draco-Umbratilis has already done a PR and updated it to add it to ProjectConfig.
Can you guys take a look at that and see what, if anything, needs to be done before it's merged in?
No sense in reinventing the wheel here.
Thanks!
I'd forgotten about that PR - let's try to land it!
Released in 26.2.0
Most helpful comment
I use jest to drive selenium tests and it reports a test that takes 12 seconds as being slow (the duration is highlighted in red). In this context 12 seconds is fine.
In
jest.config.jsI'd like an option to change the defaultThe value is hardcoded at 5 seconds at the moment. https://github.com/facebook/jest/blob/b4897796bcbcb972234ef699b3e9e0f6b8724132/packages/jest-reporters/src/get_result_header.js#L44-L46
https://stackoverflow.com/questions/54893177/jest-threshold-for-a-test-to-be-reported-as-slow