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

add `--testTimeout` cli option from jest

Open skratchdot opened this issue 2 years ago • 4 comments

Thanks for the work on this great library!

We are using it and are experiencing errors like:

thrown: "Exceeded timeout of 15000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

We've tried the --maxWorkers suggestion from the docs. Instead of ejecting and updating the testTimeout, we would prefer to pass it via our jenkins script (which runs on the CI where our tests are timing out- they work fine locally without the timeout).

Before this PR, running test-storybook --testTimeout 20000 results in:

error: unknown option '--testTimeout'

Afterwards, it will work.

To test this PR, I ran yarn build, and then tested a few commands:

set test timeout to 20ms (it should fail):

./dist/test-storybook.js --testTimeout=20
image

set test timeout to 20s (it should pass):

./dist/test-storybook.js --testTimeout=20_000
image

skratchdot avatar Nov 29 '23 04:11 skratchdot

I was just reading through some of the issues logged in this repo, and found: https://github.com/storybookjs/test-runner/issues/328

So I think this PR isn't strictly needed.

While this command errors:

test-storybook --testTimeout 20000

I think this works:

test-storybook -- --testTimeout 20000

So feel free to close this PR. But I'm also fine with it still being merged (so both of the commands above work).

skratchdot avatar Nov 30 '23 20:11 skratchdot

@skratchdot What version of the test runner are you using? 0.16.0 should allow any jest option without the additional -- .

bryanjtc avatar Dec 01 '23 03:12 bryanjtc

@skratchdot What version of the test runner are you using? 0.16.0 should allow any jest option without the additional -- .

@bryanjtc - We are using v16

Again, this works:

test-storybook -- --testTimeout 20000

This errors:

test-storybook --testTimeout 20000

You should be able to test by checking out the next branch (or v0.16.0 tag) and running:

yarn build
./dist/test-storybook.js --testTimeout 20000

which will show:

error: unknown option '--testTimeout'

and:

If you'd like this option to be supported, please open an issue at https://github.com/storybookjs/test-runner/issues/new

skratchdot avatar Dec 01 '23 04:12 skratchdot

test-storybook -- --testTimeout 20000

That works for me, thank you @skratchdot

Jero786 avatar Feb 20 '24 13:02 Jero786

Thanks a lot for your contribution @skratchdot !!

yannbf avatar May 09 '24 07:05 yannbf