test-runner icon indicating copy to clipboard operation
test-runner copied to clipboard

[FR] Allow to customize Jest timeout per test

Open FokkeZB opened this issue 3 years ago • 0 comments

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-runner v0.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);
    }
  },

FokkeZB avatar Jun 28 '22 13:06 FokkeZB