test-runner
test-runner copied to clipboard
[FR] Allow to customize Jest timeout per test
Describe the bug
I'd like to be able to modify the Jest timeout per test.
Steps to reproduce the behavior
Use await new Promise(resolve => { setTimeout(resolve, 20000); }) in a story's play() or the test-runner.js postRender().
Expected behavior
Able to set the timeout for an individual test.
Screenshots and/or logs

Environment
@storybook/test-runnerv0.2.0
Additional context
I've tried setting jest.setTimeout() based on a parameter from within preRender() but as I suspected, that doesn't affect the currently running tests, only nested tests (if you call this from the module or a describe).
async preRender(page, context) {
const { parameters } = await getStoryContext(page, context);
const timeout = parameters.testRunner?.timeout;
if (typeof timeout === 'number') {
jest.setTimeout(timeout);
}
},