diff --git a/playwright.config.ts b/playwright.config.ts index cab93b4..e412d1e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,6 +1,11 @@ import { defineConfig, devices } from '@playwright/test'; import process from 'node:process'; +const runningInVSCode = process.env.TERM_PROGRAM === 'vscode'; +const baseURL = runningInVSCode + ? 'http://localhost:4173' + : process.env.BASE_URL || 'https://vue-ts-example.oo1.dev'; + /** * Read environment variables from file. * https://github.com/motdotla/dotenv @@ -66,7 +71,7 @@ export default defineConfig({ /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ actionTimeout: 0, /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: process.env.BASE_URL || 'https://vue-ts-example.oo1.dev', + baseURL, /* Only on CI systems run the tests headless */ headless: !!process.env.CI || process.env.HEADLESS === 'true', @@ -76,16 +81,13 @@ export default defineConfig({ }, // /* Run your local dev server before starting the tests */ - // webServer: { - // /** - // * Use the dev server by default for faster feedback loop. - // * Use the preview server on CI for more realistic testing. - // * Playwright will re-use the local server if there is already a dev-server running. - // */ - // command: process.env.CI ? 'npm run preview' : 'npm run dev', - // port: process.env.CI ? 4173 : 5173, - // reuseExistingServer: !process.env.CI, - // }, + webServer: runningInVSCode + ? { + command: 'npm run build-only; npm run preview', + port: 4173, + reuseExistingServer: true, + } + : undefined, /* Folder for test artifacts such as screenshots, videos, traces, etc. */ // outputDir: 'test-results/',