microsoft/playwright-test

How to run tests longer than timeout 30s / 30000ms

srguiwiz opened this issue · 2 comments

npx folio --help says

--timeout <timeout>      Specify test timeout threshold in milliseconds (default: 10000)

which is implemented in folio's cli.js as

    if (command.timeout)
        fixtures_1.config.timeout = parseInt(command.timeout, 10);

and gets its default from folio's config.js as

    timeout: 10000,

but then it gets fixed up in playwright's index.js as

// Test timeout for e2e tests is 30 seconds.
folio_1.config.timeout = 30000;

and command line option --timeout hence has no effect.

After much investigation we found a workaround in fixtures to do this:

import { config } from "@playwright/test";
config.timeout = 60000;

This must be at top level in the fixture. If invoked inside an override or init method, then it has no effect, being too late.

We have to test filling out a really long form in one sitting on a single page, as a main use case, and 30 seconds was barely not enough.

Notably tests failed often without giving an exact cause, but along the line of Protocol error (Input.dispatchKeyEvent): Page closed and Protocol error (Page.dispatchMouseEvent): Target closed.undefined etc... Only sometimes it would explicitly say Timeout of 30000ms exceeded.

Update: To run successfully by allowing 60 seconds, we have to both use --timeout=60000 on the command line and in a fixture have

import { config } from "@playwright/test";
config.timeout = 60000;

When using the new npm install -D @playwright/test@next (gets released soon as stable), then you can do something like that:

setConfig({
  timeout: 60 * 1000,
})

See here for a full example:

Yes, a setConfig in a config.ts did work for us now to set the timeout in the new playwright-test. Thank you.