Files
upstream-tldraw/apps/dotcom/client/playwright.config.ts
upstream-mirror a774ac673a
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled
snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
2026-09-23 16:12:52 +05:00

130 lines
4.3 KiB
TypeScript

import path from 'path'
import { defineConfig, devices } from '@playwright/test'
import dotenv from 'dotenv'
const scenarioTestMatch = /.*\.scenario\.spec\.ts/
// Legacy smoke specs live in e2e/tests/smoke and are intentionally separate from the default
// scenario runner. See e2e/README.md.
const smokeTestMatch = /tests\/smoke\/.*\.spec\.ts/
// Fail fast if the dev stack does not come up: not a single test runs until http://localhost:3000
// responds, so a stuck server otherwise burns CI minutes. process-compose brings up postgres ->
// migrate -> zero-cache -> workers -> client (see apps/dotcom/process-compose.yaml); it should boot
// well within this. If a CI cold start ever legitimately needs longer, raise this rather than
// reverting to a multi-minute stuck wait.
const CI_WEB_SERVER_TIMEOUT_MS = 180_000
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
dotenv.config({ path: path.resolve(__dirname, '.env.local') })
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
// In CI the webServer below starts the full dotcom dev stack (including Docker). Tear it down
// afterwards so containers and ports do not leak between runs. No-op locally (reused server).
globalTeardown: process.env.CI ? require.resolve('./e2e/global.teardown.ts') : undefined,
// Run files in parallel, but tests within a file in sequence. This is important for certain
// tests that use shared system resources like the clipboard, which should all be kept in the
// same file.
fullyParallel: !!process.env.STAGING_TESTS,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
// For now we need to use 1 worker for dev as well, otherwise clearing the db fails since there might
// an open connection to the db when we are trying to clear it.
workers: process.env.STAGING_TESTS ? 6 : process.env.CI ? 2 : 3,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI ? [['list'], ['github'], ['html', { open: 'never' }]] : 'list',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
timeout: 30 * 1000,
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
video: 'retain-on-failure',
launchOptions: {
// Uncomment this to make the browser slow down. Useful when debugging in the headed mode.
// slowMo: 1000,
},
},
/* Configure projects for major browsers */
projects: [
{ name: 'global-setup', testMatch: /global\.setup\.ts/ },
{ name: 'global-staging-setup', testMatch: /global-staging\.setup\.ts/ },
{
name: 'chromium',
testMatch: smokeTestMatch,
use: {
...devices['Desktop Chrome'],
},
dependencies: ['global-setup'],
},
{
name: 'chromium-scenarios',
testMatch: scenarioTestMatch,
fullyParallel: true,
use: {
...devices['Desktop Chrome'],
},
dependencies: ['global-setup'],
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
{
name: 'staging',
use: {
...devices['Desktop Chrome'],
storageState: 'e2e/.auth/staging.json',
},
testMatch: /staging\.spec\.ts/,
dependencies: ['global-staging-setup'],
},
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
//
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
/* Run your local dev server before starting the tests */
webServer: {
command: process.env.CI ? 'VITE_PREVIEW=1 yarn dev-app' : 'yarn preview-app',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
cwd: path.join(__dirname, '../../../'),
timeout: process.env.CI ? CI_WEB_SERVER_TIMEOUT_MS : 300_000,
},
})