diff --git a/packages/playwright/src/common/config.ts b/packages/playwright/src/common/config.ts index 7bc56cf4f6dba..d54c739726582 100644 --- a/packages/playwright/src/common/config.ts +++ b/packages/playwright/src/common/config.ts @@ -265,7 +265,7 @@ export function toReporters(reporters: BuiltInReporter | ReporterDescription[] | export const builtInReporters = ['list', 'line', 'dot', 'json', 'junit', 'null', 'github', 'html', 'blob', 'markdown'] as const; export type BuiltInReporter = typeof builtInReporters[number]; -export type ContextReuseMode = 'none' | 'force' | 'when-possible'; +export type ContextReuseMode = 'none' | 'when-possible'; function resolveScript(id: string | undefined, rootDir: string): string | undefined { if (!id) diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index 9b8b4bc55be22..0a6651f3626a5 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -356,8 +356,8 @@ const playwrightFixtures: Fixtures = ({ _reuseContext: [async ({ video, _optionContextReuseMode }, use) => { let mode = _optionContextReuseMode; if (process.env.PW_TEST_REUSE_CONTEXT) - mode = process.env.PW_TEST_REUSE_CONTEXT === 'when-possible' ? 'when-possible' : (process.env.PW_TEST_REUSE_CONTEXT ? 'force' : 'none'); - const reuse = mode === 'force' || (mode === 'when-possible' && normalizeVideoMode(video) === 'off'); + mode = 'when-possible'; + const reuse = mode === 'when-possible' && normalizeVideoMode(video) === 'off'; await use(reuse); }, { scope: 'worker', _title: 'context' } as any], diff --git a/packages/playwright/src/runner/testServer.ts b/packages/playwright/src/runner/testServer.ts index 0809bd43d7ca5..e7670c3548abc 100644 --- a/packages/playwright/src/runner/testServer.ts +++ b/packages/playwright/src/runner/testServer.ts @@ -308,6 +308,7 @@ class TestServerDispatcher implements TestServerInterface { reporter: params.reporters ? params.reporters.map(r => [r]) : undefined, use: { trace: params.trace === 'on' ? { mode: 'on', sources: false, _live: true } : (params.trace === 'off' ? 'off' : undefined), + video: 'off', headless: params.headed ? false : undefined, _optionContextReuseMode: params.reuseContext ? 'when-possible' : undefined, _optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : undefined, diff --git a/tests/playwright-test/playwright.reuse.spec.ts b/tests/playwright-test/playwright.reuse.spec.ts index 799b6fa3d7280..0620195f65c7f 100644 --- a/tests/playwright-test/playwright.reuse.spec.ts +++ b/tests/playwright-test/playwright.reuse.spec.ts @@ -85,35 +85,6 @@ test('should not reuse context with video if mode=when-possible', async ({ runIn expect(fs.existsSync(testInfo.outputPath('test-results', 'reuse-two', 'video.webm'))).toBeFalsy(); }); -test('should reuse context and disable video if mode=force', async ({ runInlineTest }, testInfo) => { - const result = await runInlineTest({ - 'playwright.config.ts': ` - export default { - use: { video: 'on' }, - }; - `, - 'reuse.test.ts': ` - import { test, expect } from '@playwright/test'; - let lastContextGuid; - - test('one', async ({ context, page }) => { - lastContextGuid = context._guid; - await page.waitForTimeout(2000); - }); - - test('two', async ({ context, page }) => { - expect(context._guid).toBe(lastContextGuid); - await page.waitForTimeout(2000); - }); - `, - }, { workers: 1 }, { PW_TEST_REUSE_CONTEXT: '1' }); - - expect(result.exitCode).toBe(0); - expect(result.passed).toBe(2); - expect(fs.existsSync(testInfo.outputPath('test-results', 'reuse-one', 'video.webm'))).toBeFalsy(); - expect(fs.existsSync(testInfo.outputPath('test-results', 'reuse-two', 'video.webm'))).toBeFalsy(); -}); - test('should reuse context with trace if mode=when-possible', async ({ runInlineTest }, testInfo) => { const result = await runInlineTest({ 'playwright.config.ts': `