Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/src/test-api/class-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ test('update user settings', {
});
```

The built-in `exclusive` lock runs the test only when no other tests are running.
The built-in `-exclusive-` lock runs the test only when no other tests are running.

Learn more about [test locks](../test-parallel.md#test-locks).

Expand Down Expand Up @@ -1992,4 +1992,3 @@ test('test with locale', async ({ page }) => {

An object with local options.


4 changes: 2 additions & 2 deletions docs/src/test-parallel-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ test.describe.configure({ lock: 'user-settings' });

Playwright acquires all the locks of a test before the test starts and releases them when it finishes.

The built-in `exclusive` lock runs a test in isolation: it starts only when no other tests are running, and no other tests start until it finishes. All other tests continue to run in parallel with each other. This is useful for a few tests that are sensitive to any concurrent activity, for example tests that measure performance or restart a shared service.
The built-in `-exclusive-` lock runs a test in isolation: it starts only when no other tests are running, and no other tests start until it finishes. All other tests continue to run in parallel with each other. This is useful for a few tests that are sensitive to any concurrent activity, for example tests that measure performance or restart a shared service.

```js
test('restart the server', { lock: 'exclusive' }, async () => {
test('restart the server', { lock: '-exclusive-' }, async () => {
// No other test runs while this one is running.
});
```
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/runner/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type { TestError, TestResult, TestStep } from '../../types/testReporter';

export type EnvByProjectId = Map<string, Record<string, string | undefined>>;

const exclusiveLock = 'exclusive';
const exclusiveLock = '-exclusive-';

export class Dispatcher {
// Worker slot is claimed when it has jobDispatcher assigned.
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2898,7 +2898,7 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* });
* ```
*
* The built-in `exclusive` lock runs the test only when no other tests are running.
* The built-in `-exclusive-` lock runs the test only when no other tests are running.
*
* Learn more about [test locks](https://playwright.dev/docs/test-parallel#test-locks).
* @param title Test title.
Expand Down Expand Up @@ -2997,7 +2997,7 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* });
* ```
*
* The built-in `exclusive` lock runs the test only when no other tests are running.
* The built-in `-exclusive-` lock runs the test only when no other tests are running.
*
* Learn more about [test locks](https://playwright.dev/docs/test-parallel#test-locks).
* @param title Test title.
Expand Down
12 changes: 6 additions & 6 deletions tests/playwright-test/test-locks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test('should not run tests with the same lock at the same time', async ({ runInl
expect(conflictingOverlaps(result.outputLines, [['test1', 'test2']])).toEqual([]);
});

test('should run tests with different locks at the same time', async ({ runInlineTest }) => {
test('should run tests with different locks at the same time', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43797' } }, async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
export default { fullyParallel: true };
Expand All @@ -81,7 +81,7 @@ test('should run tests with different locks at the same time', async ({ runInlin
'a.test.ts': `
import { test } from '@playwright/test';
import { signalAndWait } from './helper';
test('test1', { lock: 'lock-a' }, async () => {
test('test1', { lock: 'exclusive' }, async () => {
// Only finishes when both tests run at the same time.
await signalAndWait('a.txt', 'b.txt');
});
Expand Down Expand Up @@ -241,15 +241,15 @@ test('should validate lock in test details', async ({ runInlineTest }) => {
expect(result.output).toContain('details.lock');
});

test('should run tests with the exclusive lock in isolation', async ({ runInlineTest }) => {
test('should run tests with the exclusive lock in isolation', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43797' } }, async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
export default { fullyParallel: true };
`,
'a.test.ts': `
import { test } from '@playwright/test';
${lockedTest('test1', 500)}
${lockedTest('test2', 500, 'exclusive')}
${lockedTest('test2', 500, '-exclusive-')}
${lockedTest('test3', 500)}
`,
'b.test.ts': `
Expand All @@ -264,14 +264,14 @@ test('should run tests with the exclusive lock in isolation', async ({ runInline
expect(conflictingOverlaps(result.outputLines, others.map(name => ['test2', name]))).toEqual([]);
});

test('should retry tests with the exclusive lock in isolation', async ({ runInlineTest }) => {
test('should retry tests with the exclusive lock in isolation', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43797' } }, async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
export default { fullyParallel: true, retries: 1 };
`,
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('test1', { lock: 'exclusive' }, async ({}, testInfo) => {
test('test1', { lock: '-exclusive-' }, async ({}, testInfo) => {
console.log('\\n%%begin:test1-' + testInfo.retry);
await new Promise(f => setTimeout(f, 500));
console.log('\\n%%end:test1-' + testInfo.retry);
Expand Down
Loading