You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Allow retryStrategy: 'isolated' in test.describe.configure() for tests requiring zero background workers #43351
Playwright recently introduced retryStrategy: 'isolated', however, it is currently restricted to the global testConfig. It'd be very helpful if retryStrategy was implemented at the test file level in test.describe.configure() so isolated retries can be targeted only to tests that require zero concurrency to pass.
Existing features do not solve this
Why lock doesn't work:
lock is an opt-in named mutex, not a runner-wide exclusive lock:
If Test A has { lock: 'foo' }, it only blocks other tests that also declare { lock: 'foo' }.
All other unlocked tests in the repository still run concurrently in background workers alongside Test A.
To achieve true isolation with lock, we would have to add { lock: 'foo' } to every single test in the entire codebase, which would completely eliminate parallel execution for the whole test run.
Why global retryStrategy: 'isolated' in playwright.config.ts is insufficient:
It is currently an all-or-nothing global flag.
It forces every failed test across thousands of unrelated files to defer its retries to the single-worker tail phase, even if 99% of tests are completely stateless and should just retry immediately.
Example
import { test, expect } from '@playwright/test';
// Only this suite will be retried in isolation if concurrency causes a failure
test.describe.configure({
retries: 1,
retryStrategy: 'isolated',
});
test.describe('tests that fail under concurrent execution', () => {
test('exclusive test', async ({ page }) => {
/* Runs in parallel initially.
If it collides with another worker and fails, it is retried
at the end of the run with no other tests running concurrently. */
});
});
Expected Behaviour:
Global/default retry strategy remains 'immediate' (or whatever is set in playwright.config.ts).
Test files configured with override, retryStrategy: 'isolated' at the test.describe level are queued to run in isolation (one worker, no other concurrent tests running) upon failure.
Motivation
We have specific tests that require zero-concurrency isolation (meaning no other worker threads can be running anywhere in the runner at the same time) to pass as the nature of these tests make them extremely vulnerable to cross-test interference. We want our test suite to run in parallel by default but if these specific tests fail under concurrency, we want their retries to run in isolation without background workers.
+1, this would be super useful. Having retryStrategy: 'isolated' only as a global config option is pretty restrictive when only a handful of heavy/stateful tests actually collide under concurrency.
Since retries, timeout, and mode can already be configured per-suite in test.describe.configure(), supporting retryStrategy there feels like a natural fit. In the dispatcher (dispatcher.ts), it would just be checking test._retryStrategy ?? config.retryStrategy when sorting failed tests into isolatedRetriesJob vs remaining.
If the maintainers are open to supporting this, feel free to assign it to me
I'd love to take this on, dig deeper into the runner edge cases, and put together a PR with tests.
Hi, the Playwright bot looked into this on my behalf. This asks for the same thing as #43194, which was closed. You can already get full isolation for these tests, on the first attempt as well as on retries, by moving them to a separate project that depends on the rest and uses one worker:
exclusive starts only after every main test has finished, and runs its tests one at a time, with retries as usual. I checked this on tip-of-tree with 4 workers: the first exclusive test started after the last main test ended, and the next one started after it finished.
Yury Semikhatsky (@yury-s) Thanks for reopening and exploring this. While seperate projects works locally, dependencies: ['main] doesn't work in CI where we --shard our tests. I already attempted something similar because I agree, running these exclusive tests serially from the start is the ideal scenario.
Playwright treats project dependencies as un-sharded prerequisites. Any shard that gets assigned tests from exclusive will execute the entiremain project from start to finish before running exclusive. If tests from exclusive are distributed across shards, main ends up being duplicated on each of those shards, significantly multiplying CI runtime. This was touched a while back in #29102.
Supporting retryStrategy: isolated via test.describe.configure() offers a granular control that doesn't break test distribution across shards. I can add a conditional if (testInfo.retry < 1) throw new Error('Run this test in isolation) at the top of test logic which prevents wasted runtime.
Note: Our CI shards each spin up their own docker instance of our app, so cross-shard concurrency is a non-issue. Could be problematic otherwise.
Hi, the Playwright bot looked into this on my behalf.
The sharding objection is right. Dependency projects are taken out before the shard filter and added back whole (runner/loadUtils.ts), so every shard that gets an exclusive test runs all of main first. The separate-project setup doesn't carry over to sharded CI, which leaves this request standing. The runtime side is small; what needs a decision first is the shape of the API.
What the runner does today, as far as it bears on the design:
retryStrategy: 'isolated' already works per shard: each shard holds back its retries until its own workers are idle and never coordinates with other shards. A per-suite option would behave the same way, which fits a setup where every shard has its own app instance.
The dispatcher sorts failed tests into an immediate job or an isolated job in one place (JobDispatcher in runner/dispatcher.ts); reading the test's strategy there instead of config.retryStrategy is the whole runtime change. The scheduler already starts an isolated job only when every worker is idle and always picks queued regular jobs first, so immediate and isolated retries can coexist in one run without touching it.
Open questions before a PR:
Scope.retries can be set in the config, per project and in test.describe.configure(). Should retryStrategy follow it to all three? A project-level option on its own already covers this case without project dependencies, and it shards fine:
Serial suites. All tests of a failed serial suite are retried together as one job. A retryStrategy set on a suite nested inside a serial suite would split that job in two. The option would have to come from the serial root, or be rejected inside a serial suite the way a conflicting mode is today.
Activity
alok-108 commentedon Oct 13, 2026
+1, this would be super useful. Having
retryStrategy: 'isolated'only as a global config option is pretty restrictive when only a handful of heavy/stateful tests actually collide under concurrency.Since
retries,timeout, andmodecan already be configured per-suite intest.describe.configure(), supportingretryStrategythere feels like a natural fit. In the dispatcher (dispatcher.ts), it would just be checkingtest._retryStrategy ?? config.retryStrategywhen sorting failed tests intoisolatedRetriesJobvsremaining.alok-108 commentedon Oct 13, 2026
If the maintainers are open to supporting this, feel free to assign it to me
I'd love to take this on, dig deeper into the runner edge cases, and put together a PR with tests.
yury-s commentedon Oct 13, 2026
Hi, the Playwright bot looked into this on my behalf. This asks for the same thing as #43194, which was closed. You can already get full isolation for these tests, on the first attempt as well as on retries, by moving them to a separate project that depends on the rest and uses one worker:
exclusivestarts only after everymaintest has finished, and runs its tests one at a time, withretriesas usual. I checked this on tip-of-tree with 4 workers: the firstexclusivetest started after the lastmaintest ended, and the next one started after it finished.Investigated locally by the Playwright bot
yury-s commentedon Oct 14, 2026
One missing piece is failFast on the project
main, so that we if it fails the dependency project still runs.toduyemi commentedon Oct 14, 2026
Yury Semikhatsky (@yury-s) Thanks for reopening and exploring this. While seperate projects works locally,
dependencies: ['main]doesn't work in CI where we--shardour tests. I already attempted something similar because I agree, running theseexclusivetests serially from the start is the ideal scenario.Playwright treats project dependencies as un-sharded prerequisites. Any shard that gets assigned tests from
exclusivewill execute the entiremainproject from start to finish before runningexclusive. If tests fromexclusiveare distributed across shards,mainends up being duplicated on each of those shards, significantly multiplying CI runtime. This was touched a while back in #29102.Supporting
retryStrategy: isolatedvia test.describe.configure() offers a granular control that doesn't break test distribution across shards. I can add a conditionalif (testInfo.retry < 1) throw new Error('Run this test in isolation)at the top of test logic which prevents wasted runtime.Note: Our CI shards each spin up their own docker instance of our app, so cross-shard concurrency is a non-issue. Could be problematic otherwise.
alok-108 commentedon Oct 14, 2026
yury-s commentedon Oct 15, 2026
Hi, the Playwright bot looked into this on my behalf.
The sharding objection is right. Dependency projects are taken out before the shard filter and added back whole (
runner/loadUtils.ts), so every shard that gets anexclusivetest runs all ofmainfirst. The separate-project setup doesn't carry over to sharded CI, which leaves this request standing. The runtime side is small; what needs a decision first is the shape of the API.What the runner does today, as far as it bears on the design:
retryStrategy: 'isolated'already works per shard: each shard holds back its retries until its own workers are idle and never coordinates with other shards. A per-suite option would behave the same way, which fits a setup where every shard has its own app instance.JobDispatcherinrunner/dispatcher.ts); reading the test's strategy there instead ofconfig.retryStrategyis the whole runtime change. The scheduler already starts an isolated job only when every worker is idle and always picks queued regular jobs first, so immediate and isolated retries can coexist in one run without touching it.Open questions before a PR:
retriescan be set in the config, per project and intest.describe.configure(). ShouldretryStrategyfollow it to all three? A project-level option on its own already covers this case without project dependencies, and it shards fine:retryStrategyset on a suite nested inside a serial suite would split that job in two. The option would have to come from the serial root, or be rejected inside a serial suite the way a conflictingmodeis today.Investigated locally by the Playwright bot