Skip to content

Test suite #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 107 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
c40b00c
build(deps): add Playwright
coopbri Dec 31, 2024
317427e
build(deps,scripts): add Happy DOM, Bun types, RTL, unit and E2E test…
coopbri Jan 2, 2025
bd7e4ce
feature: add bunfig.toml, test setup
coopbri Jan 2, 2025
d792e1f
chore(knip): add test config
coopbri Jan 2, 2025
7ac87ad
build(deps,scripts): add 'ms', dedicated Next.js dev script
coopbri Jan 2, 2025
91df514
build(deps): add msw, msw graphql codegen plugin
coopbri Jan 2, 2025
4d486f8
feature(graphql): add MSW plugin
coopbri Jan 2, 2025
f2182f8
docs(readme): update instructions for test env vars
coopbri Jan 2, 2025
33cb127
feature: add Playwright config
coopbri Jan 2, 2025
25ffa0e
ci: add test workflow
coopbri Jan 2, 2025
263e9f3
ci(test): set artifact name with shard ID
coopbri Jan 2, 2025
c9778d1
ci(test): set artifact path with shard ID
coopbri Jan 2, 2025
71bfc0f
ci(test): correct shard artifacts (use proper job)
coopbri Jan 2, 2025
de51ef2
ci(test): resolve invalid character error
coopbri Jan 2, 2025
5018629
ci(test): resolve invalid character error
coopbri Jan 2, 2025
07c76d1
ci(test): iterate over uploaded blob reports for merge
coopbri Jan 2, 2025
2ee3bcd
ci(test): fix merge iteration
coopbri Jan 2, 2025
514bc60
ci(test): fix merge iteration
coopbri Jan 2, 2025
42872ec
ci(test): disable merge job, add discussion TODO
coopbri Jan 2, 2025
57e926e
ci(test): update TODO
coopbri Jan 2, 2025
37ee1b1
test(e2e,auth): add basic auth (sign in) test
coopbri Jan 2, 2025
2d8bed1
ci(test): add test credential env vars
coopbri Jan 2, 2025
3d690a6
chore(test,auth): remove brackets
coopbri Jan 2, 2025
e412820
ci(test): add debug flag
coopbri Jan 2, 2025
acb5000
docs(env): improve comment
coopbri Jan 2, 2025
dce3b6b
ci(test): set Bun setup action version from v1 to v2, remove latest flag
coopbri Jan 2, 2025
747cdbc
test(e2e): add CI test tests
coopbri Jan 2, 2025
363dc13
test(e2e): implement page object model pattern with fixtures
coopbri Jan 2, 2025
dd6e488
ci(test): fix Playwright shard execution
coopbri Jan 2, 2025
443c994
test(e2e,auth): remove example tests
coopbri Jan 2, 2025
4c1e514
ci(test): add env vars
coopbri Jan 2, 2025
82e8ee8
ci(test): fix env var access typo
coopbri Jan 2, 2025
bf49ef8
ci(test): inject '.env.test' to E2E job
coopbri Jan 2, 2025
5cb89ee
feature(env): add test env var file
coopbri Jan 2, 2025
5564662
build(deps,scripts): create proxy unit test script, add GraphQL Codeg…
coopbri Jan 4, 2025
7e24d30
feature(scripts): add unit test execution script
coopbri Jan 4, 2025
a5c1dde
chore(test,playwright): add TODO
coopbri Jan 4, 2025
cfc3c7d
test: add mocks
coopbri Jan 4, 2025
e215e10
chore(test,e2e,auth): add TODO
coopbri Jan 4, 2025
fed8367
docs: add JSDoc
coopbri Jan 4, 2025
fc07e13
test(e2e,msw): inject MSW Node.js server instance
coopbri Jan 4, 2025
3145050
chore(knip): update config
coopbri Jan 4, 2025
615ea46
refactor(env): update exports, knip ignores
coopbri Jan 4, 2025
4241b17
docs(graphql): fix typo
coopbri Jan 4, 2025
bbea32e
style(feature-card): center content
coopbri Jan 4, 2025
4362235
chore(graphql): update generated artifacts
coopbri Jan 4, 2025
ac79f38
Merge branch 'master' into test/suite
coopbri Jan 4, 2025
715cc8f
fix: track graphql.mock.ts artifact
coopbri Jan 4, 2025
8ffbead
ci(test): add debug step
coopbri Jan 4, 2025
fa9c9be
refactor(scripts,test): 'zsh' -> 'sh'
coopbri Jan 4, 2025
0b0a32d
test: use zsh
coopbri Jan 4, 2025
b0e001d
fix: fix glob expansion for non-zsh shells
coopbri Jan 4, 2025
c9aec7a
fix: fix glob expansion for non-zsh shells
coopbri Jan 4, 2025
8c21957
fix: fix glob expansion for non-zsh shells
coopbri Jan 4, 2025
c3903b2
test: replace test shell script with package.json script
coopbri Jan 4, 2025
e4bbaf8
feature: add MSW browser service worker and config
coopbri Jan 4, 2025
0ec2942
test(mocks): add HIDRA and WalletConnect handlers
coopbri Jan 4, 2025
d159b44
chore(e2e,auth): add warning about app router support
coopbri Jan 4, 2025
0c79707
ci(test): remove Playwright debug flag
coopbri Jan 4, 2025
552d7b7
ci(test): conditionally upload test result artifacts
coopbri Jan 4, 2025
6311cd7
ci(test): disable sharding
coopbri Jan 4, 2025
1134cc9
build(deps,scripts): add RTL extensions, fix Bun test pattern match
coopbri Jan 4, 2025
fa3191a
test: enhance unit test setup file
coopbri Jan 4, 2025
2f59a98
test: add custom render implementation
coopbri Jan 4, 2025
5ed9f97
test: add theme toggle tests
coopbri Jan 4, 2025
b84da4a
ci(test): inject WalletConnect project ID env var to unit test job
coopbri Jan 4, 2025
ed1301a
test(theme-toggle): add TODO
coopbri Jan 4, 2025
6eaae4b
test(unit): add more providers to custom 'render'
coopbri Jan 4, 2025
00f0b74
test(msw): initialize MSW fixtures on app start behind feature flag
coopbri Jan 4, 2025
88caf6f
test: add home page (todo), landing page tests
coopbri Jan 4, 2025
37e6c1d
test(mocks): add and inject Next.js app router mocks
coopbri Jan 5, 2025
c281384
docs: add JSDoc to test files
coopbri Jan 5, 2025
c7a650c
test: add skipped dashboard page test
coopbri Jan 5, 2025
63cc341
docs: add MSW unit test integration reference article
coopbri Jan 5, 2025
9e5e323
docs(handlers,walletconnect): remove trailing slash
coopbri Jan 5, 2025
cc12ff7
build(deps): upgrade web3 dependencies
coopbri Jan 5, 2025
43be2ff
chore(graphql): enable shared add plugin in mock artifacts
coopbri Jan 5, 2025
69f3cc0
chore: format
coopbri Jan 5, 2025
b16e735
docs(tests,theme-toggle): update TODO
coopbri Jan 5, 2025
891111f
docs(tests,theme-toggle): update TODO
coopbri Jan 5, 2025
cb22e26
ci: trigger build
coopbri Jan 5, 2025
c6a3e26
chore(knip): update test patterns
coopbri Jan 9, 2025
1ac3e70
docs(readme): remove instructions for test env vars
coopbri Jan 9, 2025
6f443eb
build(scripts): explicitly inject env var files into test scripts
coopbri Jan 9, 2025
9820d01
chore(package): move msw config so it doesn't get lost in the sauce
coopbri Jan 9, 2025
5866668
build(deps): upgrade dependencies
coopbri Jan 9, 2025
3322c7d
Merge branch 'master' into test/suite
coopbri Jan 10, 2025
2a1cc3e
chore: format
coopbri Jan 10, 2025
15550e7
ci(test): remove E2E test artifact upload job
coopbri Jan 10, 2025
fae2a2c
chore: update mock user ID env var name
coopbri Jan 10, 2025
615b335
build(deps): add ms DT types
coopbri Jan 10, 2025
c770f58
fix(docker): fix build
coopbri Jan 10, 2025
06383c0
build(deps): upgrade knip, typescript
coopbri Jan 10, 2025
563b588
chore(ts): set bun module types explicitly for language server support
coopbri Jan 10, 2025
a70788e
chore: remove instances of `BlockchainProvider` in test files
coopbri Jan 10, 2025
296953c
build(deps): remove '@types/bun'
coopbri Jan 10, 2025
1cf2d61
Merge branch 'master' into test/suite
coopbri Jan 14, 2025
0d44e49
Merge branch 'master' into test/suite
coopbri Jan 15, 2025
03dd288
chore: format
coopbri Jan 15, 2025
23624d0
Merge branch 'master' into test/suite
coopbri Jan 16, 2025
0795d27
build(deps): upgrade dependencies
coopbri Jan 16, 2025
b7759cf
chore: format
coopbri Jan 16, 2025
04dc5d8
fix: fix build issues
coopbri Jan 16, 2025
a68322e
ci: trigger build
coopbri Jan 16, 2025
d606562
chore: remove WalletConnect content
coopbri Jan 16, 2025
6b57f4e
chore(playwright): remove unused import
coopbri Jan 16, 2025
014d8ab
ci(test): pin Bun 1.1.42
coopbri Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .env.local.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ AUTH_KEYCLOAK_SECRET=""
# NB: an auth secret can be generated and injected automatically with `npx auth`, see https://cli.authjs.dev
AUTH_SECRET=""

# NB: mocked user HIDRA ID from locally seeded database.
# TODO: remove once keycloak / hidra are synced with database and mock data is no longer needed (https://linear.app/omnidev/issue/OMNI-147/replace-mock-user-id-flow-with-hidra-integration)
NEXT_PUBLIC_MOCK_USER_HIDRA_ID=""
# testing
# username and password must be valid credentials for a user within the `test` realm
TEST_USERNAME=""
TEST_PASSWORD=""
# whether to enable MSW for mocked network requests/responses
ENABLE_MSW=""
# mocked user ID from local, seeded database
# TODO: remove once HIDRA is synced with database and mock data is no longer needed (https://linear.app/omnidev/issue/OMNI-147/replace-mock-user-id-flow-with-hidra-integration)
NEXT_PUBLIC_MOCK_USER_ID=""
4 changes: 4 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#test-environment-variables
AUTH_KEYCLOAK_ISSUER="https://hidra.omni.dev/realms/test"
NEXT_PUBLIC_API_BASE_URL="http://127.0.0.1:4000/graphql"
APP_ENV="test"
59 changes: 59 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Test 🧪

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test_unit:
name: Run unit tests 🃏
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.1.42
# - uses: ArtiomTr/jest-coverage-report-action@v2
# with:
# package-manager: bun
# test-script: bun test:coverage
# annotations: failed-tests
# TODO replace below with commented job above, blocked by Bun not yet supporting a JSON coverage reporter for the action to consume nor generate (similar: https://github.com/oven-sh/bun/issues/4099)
- name: Install dependencies
run: bun install
- name: Run unit tests
run: bun run test

test_e2e:
name: Run E2E tests 🗺️
timeout-minutes: 3
runs-on: ubuntu-latest
# TODO enable, disabled for now while E2E tests are simple. No need to shard early
# strategy:
# fail-fast: false
# shard tests across 4 nodes (https://playwright.dev/docs/test-sharding)
# matrix:
# shard: [1/4, 2/4, 3/4, 4/4]
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Install Playwright
run: bunx playwright install --with-deps
- name: Load test environment variables
uses: falti/[email protected]
with:
path: .env.test
- name: Run E2E tests
# TODO enable, disabled for now while E2E tests are simple. No need to shard early
# run: bun test:e2e --shard ${{ matrix.shard }}
run: bun test:e2e
env:
TEST_USERNAME: ${{ secrets.TEST_USERNAME }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
AUTH_KEYCLOAK_SECRET: ${{ secrets.AUTH_KEYCLOAK_SECRET }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ coverage
!.env
!.env.development
!.env.production
!.env.test
!.env.local.template

# misc
next-env.d.ts

**/generated/*
!**/generated/.gitignore
!**/generated/.gitignore
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM base AS deps
WORKDIR /app

# install dependencies
COPY package.json bun.lockb panda.config.ts ./
COPY package.json bun.lock panda.config.ts ./
# `apt` commands below are a workaround for blocked builds on some systems: https://github.com/oven-sh/bun/issues/9807#issuecomment-2218837172
RUN apt update && apt install python3 python3-pip make g++ -y
RUN bun install --frozen-lockfile
Expand All @@ -24,8 +24,6 @@ COPY . .
# disable telemetry during build (https://nextjs.org/telemetry)
ENV NEXT_TELEMETRY_DISABLED=1

ARG WALLETCONNECT_PROJECT_ID

RUN bun prepare
RUN bun run build

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Backfeed is an open-source feedback reporting platform.

## Local Development

First, `cp .env.local.template` to `.env.local` and fill in the values.
First, `cp .env.local.template .env.local` and fill in the values.

### Building and Running (Native)

Expand Down
831 changes: 505 additions & 326 deletions bun.lock
100755 → 100644

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
telemetry = false

# https://bun.sh/docs/runtime/bunfig#test-runner
[test]
preload = "test/test.setup.ts"
5 changes: 4 additions & 1 deletion knip.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ const knipConfig: KnipConfig = {
"src/app/{manifest,sitemap,robots}.ts",
"src/app/**/{icon,apple-icon}.{ts,tsx}",
"src/app/**/{opengraph,twitter}-image.{ts,tsx}",
"src/test/**/*.{ts,tsx}",
],
// NB: files are reported as unused if they are in the set of project files, but not in the set of files resolved from the entry files. See: https://knip.dev/guides/configuring-project-files
project: ["src/**/*.{ts,tsx}"],
// NB: Modified from the default GraphQL Codegen configuration, see: https://knip.dev/reference/plugins/graphql-codegen
"graphql-codegen": {
config: ["package.json", "src/lib/graphql/codegen.config.ts"],
},
ignore: ["panda.config.ts", "src/generated/**"],
ignore: ["panda.config.ts", "src/__mocks__/**", "src/generated/**"],
ignoreDependencies: [
// @omnidev/sigil peer dependency
"@ark-ui/react",
// included by Next.js metapackage, used in Playwright config
"@next/env",
// used by GraphQL Code Generator scripts
"dotenv",
],
Expand Down
1 change: 0 additions & 1 deletion next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const nextConfig: NextConfig = {
// enable standalone mode for running in a container (https://github.com/vercel/next.js/tree/canary/examples/with-docker#in-existing-projects)
output: "standalone",
env: {
WALLETCONNECT_PROJECT_ID: process.env.WALLETCONNECT_PROJECT_ID,
// below are safe to be public, but `NEXT_PUBLIC_` is not used because Auth.js uses these to automatically set its own Keycloak provider configuration
AUTH_KEYCLOAK_ID: process.env.AUTH_KEYCLOAK_ID,
AUTH_KEYCLOAK_ISSUER: process.env.AUTH_KEYCLOAK_ISSUER,
Expand Down
59 changes: 39 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,76 @@
"name": "backfeed",
"private": true,
"scripts": {
"dev": "rm -rf .next && concurrently --kill-others --names \"GRAPHQL-CODEGEN,PANDA,CLIENT\" -c \"bgBlue.bold,bgYellow.bold,bgMagenta.bold\" \"bun graphql:generate:watch\" \"bun panda --watch\" \"next dev --turbo\"",
"dev": "rm -rf .next && concurrently --kill-others --names \"GRAPHQL-CODEGEN,PANDA,CLIENT\" -c \"bgBlue.bold,bgYellow.bold,bgMagenta.bold\" \"bun graphql:generate:watch\" \"bun panda --watch\" \"bun dev:next\"",
"dev:next": "next dev --turbo",
"build": "next build",
"start": "next start",
"check": "biome check src",
"format": "biome format --write src",
"lint": "biome lint src",
"test": "bun test --env-file .env.local --env-file .env.test .test",
"test:e2e": "NODE_ENV=test bun run --env-file .env.local --env-file .env.test playwright test",
"graphql:generate": "NODE_PATH=src/ dotenv -e .env.development -- graphql-codegen --config src/lib/graphql/codegen.config.ts",
"graphql:generate:watch": "bun graphql:generate -w",
"knip": "knip-bun --cache --tags=-knipignore",
"prepare": "panda codegen && husky"
},
"msw": {
"workerDirectory": ["public"]
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@graphql-codegen/add": "^5.0.3",
"@graphql-codegen/cli": "^5.0.3",
"@graphql-codegen/import-types-preset": "^3.0.0",
"@graphql-codegen/plugin-helpers": "^5.1.0",
"@graphql-codegen/typescript": "^4.1.2",
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
"@graphql-codegen/typescript-msw": "^3.0.0",
"@graphql-codegen/typescript-operations": "^4.4.0",
"@graphql-codegen/typescript-react-query": "^6.1.0",
"@graphql-typed-document-node/core": "^3.2.0",
"@happy-dom/global-registrator": "^16.6.0",
"@pandacss/dev": "^0.51.1",
"@types/node": "^22.10.5",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@playwright/test": "^1.49.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"@testing-library/user-event": "^14.6.0",
"@types/bun": "^1.1.16",
"@types/ms": "^0.7.34",
"@types/node": "^22.10.7",
"@types/react": "^19.0.7",
"@types/react-dom": "^19.0.3",
"concurrently": "^9.1.2",
"dotenv": "^16.4.4",
"dotenv": "^16.4.7",
"dotenv-cli": "^8.0.0",
"husky": "^9.1.6",
"knip": "^5.37.1",
"typescript": "^5.6.3"
"husky": "^9.1.7",
"knip": "^5.42.1",
"msw": "^2.7.0",
"next-router-mock": "^0.9.13",
"typescript": "^5.7.3"
},
"dependencies": {
"@ark-ui/react": "^4.4.3",
"@omnidev/sigil": "^0.12.2",
"@tanstack/react-form": "^0.41.0",
"@tanstack/react-query": "^5.20.5",
"@tanstack/react-query-devtools": "^5.20.5",
"@ark-ui/react": "^4.8.1",
"@omnidev/sigil": "^0.12.3",
"@tanstack/react-form": "^0.41.2",
"@tanstack/react-query": "^5.64.1",
"@tanstack/react-query-devtools": "^5.64.1",
"@theme-toggles/react": "^4.1.0",
"dayjs": "^1.11.10",
"dayjs": "^1.11.13",
"graphql": "^16.10.0",
"graphql-request": "^7.1.2",
"next": "^15.0.3",
"ms": "^2.1.3",
"next": "^15.1.4",
"next-auth": "^5.0.0-beta.25",
"next-themes": "^0.4.3",
"nuqs": "^2.3.0",
"next-themes": "^0.4.4",
"nuqs": "^2.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-icons": "^5.0.1",
"react-icons": "^5.4.0",
"react-infinite-scroll-hook": "^5.0.1",
"recharts": "^2.13.3",
"ts-pattern": "^5.5.0",
"recharts": "^2.15.0",
"ts-pattern": "^5.6.0",
"usehooks-ts": "^3.1.0",
"zod": "^3.24.1",
"zustand": "^5.0.3"
Expand All @@ -64,6 +82,7 @@
"bufferutil",
"esbuild",
"keccak",
"msw",
"sharp",
"utf-8-validate"
]
Expand Down
115 changes: 115 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { loadEnvConfig } from "@next/env";
import { defineConfig } from "@playwright/test";
import ms from "ms";

// import type {
// PlaywrightTestOptions,
// PlaywrightWorkerOptions,
// Project,
// } from "@playwright/test";

// TODO use Bun runtime instead of Node.js (pending https://github.com/oven-sh/bun/issues/8222). After this is resolved, consider using Playwright for running all tests including unit tests (see https://pkerschbaum.com/blog/using-playwright-to-run-unit-tests)

// type PlaywrightDevices = Project<
// PlaywrightTestOptions,
// PlaywrightWorkerOptions
// >;

// load environment variables (see https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#loading-environment-variables-with-nextenv)
loadEnvConfig(process.cwd());

/**
* Desktop devices/viewports.
*/
// TODO enable desktop viewports (https://linear.app/omnidev/issue/OMNI-156/enable-more-playwright-devices)
// const desktopDevices: PlaywrightDevices[] = [
// {
// name: "🖥️ Chromium",
// use: {
// ...devices["Desktop Chrome"],
// },
// },
// {
// name: "🖥️ Firefox",
// use: {
// ...devices["Desktop Firefox"],
// },
// },

// {
// name: "🖥️ Safari (Webkit)",
// use: {
// ...devices["Desktop Safari"],
// },
// },
// {
// name: "🖥️ Microsoft Edge",
// use: {
// channel: "msedge",
// },
// },
// ];

/**
* Mobile devices/viewports.
*/
// TODO enable mobile viewports (https://linear.app/omnidev/issue/OMNI-156/enable-more-playwright-devices)
// const mobileDevices: PlaywrightDevices[] = [
// {
// name: "📱 Chrome",
// use: {
// ...devices["Pixel 5"],
// },
// },
// {
// name: "📱 Safari",
// use: devices["iPhone 12"],
// },
// ];

/**
* Playwright configuration.
* @see https://playwright.dev/docs/test-configuration
*/
const playwrightConfig = defineConfig({
testDir: "src/__tests__",
// maximum single-test timeout
timeout: ms("3m"),
expect: {
timeout: ms("5s"),
},
// run tests within the same file in parallel
fullyParallel: true,
// TODO enable more devices than default (https://linear.app/omnidev/issue/OMNI-156/enable-more-playwright-devices)
// projects: [...desktopDevices, ...mobileDevices],
// test output reporter
reporter: process.env.CI
? // blob is used in CI to merge sharded test results (https://playwright.dev/docs/test-reporters#blob-reporter)
"blob"
: [["html", { outputFolder: "src/test/generated/report" }]],
// fail build in CI if `test.only` is left in source code
forbidOnly: !!process.env.CI,
// number of retry attempts on test failure
retries: process.env.CI ? 2 : undefined,
// use single worker to mitigate flakiness from parallel tests. Note that this effectively disables parallelization across test files. See https://playwright.dev/docs/test-parallel#worker-processes
workers: 1,
// artifact output location (screenshots, videos, traces)
outputDir: "src/generated/test-artifacts",
// run dev server before starting the tests
webServer: {
// NB: no need to run GraphQL code generation, so just the Next.js server is started here
command: "bun dev:next",
port: (process.env.PORT as unknown as number) || 3000,
timeout: ms("2m"),
// do not use an existing server on CI
reuseExistingServer: !process.env.CI,
},
use: {
headless: true,
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || "http://localhost:3000",
// retry a test with tracing if it is failing (allows analysis of DOM, console logs, network traffic, etc.)
trace: "retry-with-trace",
},
});

export default playwrightConfig;
Loading
Loading