vitest/test/ui/globalSetup.ts
yoho 4ea1f1d974
test: ui e2e (#2710)
* feat: ui test

* test: ui

* feat: no auto open browser

* fix: lint

* fix: test timeout

* fix: timeout

* fix: test

* fix: wait more times

* fix: kill

* fix: exit process

* fix: kill

* chore: update

* chore: update

* chore: update

* fix: lint

* fix: await page load

* chore: update

* fix: test

* fix: test

* fix: test

* feat: must had content

* chore: update

* chore: update

* chore: update

* fix: times

* fix: ports

* chore: update config

* fix: catch

* feat: asset command no error

* feat: log the command stdout

* fix: error

* chore: update

* chore: use the same port

* chore: update pnpm

* fix: error

* chore: update

* feat: test

* chore: update page register

* chore: ignore not close process

* fix: params

* fix: port

* feat: pipe

* feat: catch error

* feat: test report

* chore: update

* chore: update

* chore: update sna

* test: ui

* chore: update

* chore: update

* test: untilUpdated

* chore: untilUpdated

* test: format named

* test: url should update

* chore: update

* chore: fix lockfile

* chore: upate snapshot

---------

Co-authored-by: Vladimir Sheremet <sleuths.slews0s@icloud.com>
2023-02-11 21:16:23 +01:00

21 lines
585 B
TypeScript

import os from 'node:os'
import path from 'node:path'
import fs from 'fs-extra'
import type { BrowserServer } from 'playwright-chromium'
import { chromium } from 'playwright-chromium'
const DIR = path.join(os.tmpdir(), 'vitest_playwright_global_setup')
let browserServer: BrowserServer | undefined
export async function setup(): Promise<void> {
browserServer = await chromium.launchServer()
await fs.mkdirp(DIR)
await fs.writeFile(path.join(DIR, 'wsEndpoint'), browserServer.wsEndpoint())
}
export async function teardown(): Promise<void> {
await browserServer?.close()
}