From f64464527caece3071adba075e75456deedb965c Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 7 Nov 2024 21:51:49 -0600 Subject: [PATCH] actually test app --- app-playwright/playwright.config.ts | 19 ++++++++++++------- app-playwright/tests/example.spec.ts | 4 ++-- turbo.json | 5 +++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app-playwright/playwright.config.ts b/app-playwright/playwright.config.ts index 1c56cd16..e089fc19 100644 --- a/app-playwright/playwright.config.ts +++ b/app-playwright/playwright.config.ts @@ -9,6 +9,9 @@ import { defineConfig, devices } from '@playwright/test' // dotenv.config({ path: path.resolve(__dirname, '.env') }); const isCI = Boolean(process.env.CI) +const baseURL = isCI + ? 'https://localhost:3013' + : 'https://app.pentive.localhost:3013' /** * See https://playwright.dev/docs/test-configuration. @@ -28,7 +31,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', + baseURL, /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', @@ -43,7 +46,7 @@ export default defineConfig({ { name: 'firefox', - use: { ...devices['Desktop Firefox'] }, + use: { ...devices['Desktop Firefox'], ignoreHTTPSErrors: true }, }, { @@ -73,9 +76,11 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, + webServer: { + command: 'pnpm run preview', + cwd: '../app', + url: baseURL, + ignoreHTTPSErrors: true, + reuseExistingServer: false, // always use a new server because tests require a prod build due to plugins. + }, }) diff --git a/app-playwright/tests/example.spec.ts b/app-playwright/tests/example.spec.ts index 1ac56923..83c97b6b 100644 --- a/app-playwright/tests/example.spec.ts +++ b/app-playwright/tests/example.spec.ts @@ -1,10 +1,10 @@ import { test, expect } from '@playwright/test' test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/') + await page.goto('/') // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/) + await expect(page).toHaveTitle(/Pentive App/) }) test('get started link', async ({ page }) => { diff --git a/turbo.json b/turbo.json index f71533c6..079ac0c2 100644 --- a/turbo.json +++ b/turbo.json @@ -43,6 +43,11 @@ "shared-dom#tsc-build" ] }, + "app-playwright#test:run": { + "dependsOn": [ + "app#build" + ] + }, "deploy": { "dependsOn": [ "build"