|
| 1 | +import { chromium } from 'playwright' |
| 2 | +import { expect, test } from 'vitest' |
| 3 | +import { provider } from '../settings' |
| 4 | +import { runBrowserTests } from './utils' |
| 5 | + |
| 6 | +test.runIf(provider === 'playwright')('[playwright] runs in connect mode', async () => { |
| 7 | + const browserServer = await chromium.launchServer() |
| 8 | + const wsEndpoint = browserServer.wsEndpoint() |
| 9 | + |
| 10 | + const { stdout, exitCode, stderr } = await runBrowserTests({ |
| 11 | + root: './fixtures/playwright-connect', |
| 12 | + browser: { |
| 13 | + instances: [ |
| 14 | + { |
| 15 | + browser: 'chromium', |
| 16 | + name: 'chromium', |
| 17 | + connect: { |
| 18 | + wsEndpoint, |
| 19 | + }, |
| 20 | + }, |
| 21 | + ], |
| 22 | + }, |
| 23 | + }) |
| 24 | + |
| 25 | + await browserServer.close() |
| 26 | + |
| 27 | + expect(stdout).toContain('Tests 2 passed') |
| 28 | + expect(exitCode).toBe(0) |
| 29 | + expect(stderr).toBe('') |
| 30 | +}) |
| 31 | + |
| 32 | +test.runIf(provider === 'playwright')('[playwright] warns if both connect and launch mode are configured', async () => { |
| 33 | + const browserServer = await chromium.launchServer() |
| 34 | + const wsEndpoint = browserServer.wsEndpoint() |
| 35 | + |
| 36 | + const { stdout, exitCode, stderr } = await runBrowserTests({ |
| 37 | + root: './fixtures/playwright-connect', |
| 38 | + browser: { |
| 39 | + instances: [ |
| 40 | + { |
| 41 | + browser: 'chromium', |
| 42 | + name: 'chromium', |
| 43 | + connect: { |
| 44 | + wsEndpoint, |
| 45 | + }, |
| 46 | + launch: {}, |
| 47 | + }, |
| 48 | + ], |
| 49 | + }, |
| 50 | + }) |
| 51 | + |
| 52 | + await browserServer.close() |
| 53 | + |
| 54 | + expect(stdout).toContain('Tests 2 passed') |
| 55 | + expect(exitCode).toBe(0) |
| 56 | + expect(stderr).toContain('Found both connect and launch options in browser instance configuration.') |
| 57 | +}) |
0 commit comments