Skip to content

Commit 8b153c0

Browse files
authored
chore: update e2e test configs to better work with CI (#1458)
* Also adds a helpful test:e2e:ci script to test playwright tests inside of a docker image with a clean build to more closely resemble running in CI * Upgrades playwright version
1 parent 776e392 commit 8b153c0

File tree

7 files changed

+100
-30
lines changed

7 files changed

+100
-30
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
runs-on: ubuntu-24.04
104104
timeout-minutes: 15
105105
container:
106-
image: mcr.microsoft.com/playwright:v1.55.0-jammy
106+
image: mcr.microsoft.com/playwright:v1.57.0-jammy
107107
permissions:
108108
contents: read
109109
pull-requests: write

agent_docs/development.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ yarn dev
1212

1313
## Key Development Scripts
1414

15-
- `yarn app:dev`: Start API, frontend, alerts task, and common-utils in watch mode
15+
- `yarn app:dev`: Start API, frontend, alerts task, and common-utils in watch
16+
mode
1617
- `yarn lint`: Run linting across all packages
1718
- `yarn dev:int`: Run integration tests in watch mode
1819
- `yarn dev:unit`: Run unit tests in watch mode (per package)
20+
- `yarn test:e2e`: Run Playwright E2E tests (in `packages/app`)
21+
- `yarn test:e2e:ci`: Run Playwright E2E tests in CI Docker environment (in
22+
`packages/app`)
1923

2024
## Environment Configuration
2125

@@ -30,12 +34,14 @@ yarn dev
3034
- **Unit Tests**: Jest with TypeScript support
3135
- **Integration Tests**: Jest with database fixtures
3236
- **Frontend Testing**: React Testing Library + Jest
33-
- **E2E Testing**: Custom smoke tests with BATS
37+
- **E2E Testing**: Playwright (frontend) and Custom smoke tests with BATS
38+
(ingestion)
3439

3540
### Testing Patterns
3641

3742
- **TDD Approach**: Write tests before implementation for new features
38-
- **Test organization**: Tests co-located with source files in `__tests__/` directories
43+
- **Test organization**: Tests co-located with source files in `__tests__/`
44+
directories
3945
- **Mocking**: MSW for API mocking in frontend tests
4046
- **Database testing**: Isolated test databases with fixtures
4147

@@ -52,6 +58,7 @@ yarn dev:int
5258
```
5359

5460
**CI Testing Notes:**
61+
5562
- Uses separate Docker Compose configuration optimized for CI
5663
- Isolated test environment with `-p int` project name
5764
- Includes all necessary services (ClickHouse, MongoDB, OTel Collector)
@@ -79,6 +86,7 @@ yarn dev:int
7986
### Pre-commit Hooks
8087

8188
The project uses Husky + lint-staged to automatically run:
89+
8290
- Prettier for formatting
8391
- ESLint for linting
8492
- API doc generation (for external API changes)
@@ -101,11 +109,11 @@ yarn run lint
101109

102110
## File Locations Quick Reference
103111

104-
- **Config**: `packages/api/src/config.ts`, `packages/app/next.config.mjs`, `docker-compose.dev.yml`
112+
- **Config**: `packages/api/src/config.ts`, `packages/app/next.config.mjs`,
113+
`docker-compose.dev.yml`
105114
- **Models**: `packages/api/src/models/`
106115
- **API Routes**: `packages/api/src/routers/`
107116
- **Controllers**: `packages/api/src/controllers/`
108117
- **Pages**: `packages/app/pages/`
109118
- **Components**: `packages/app/src/`
110119
- **Shared Utils**: `packages/common-utils/src/`
111-

packages/app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"test:e2e": "playwright test",
2121
"test:e2e:ui": "playwright test --ui",
2222
"test:e2e:debug": "playwright test --debug",
23+
"test:e2e:ci": "../../scripts/test-e2e-ci.sh",
2324
"storybook": "storybook dev -p 6006",
2425
"storybook:build": "storybook build",
2526
"knip": "knip"
@@ -107,7 +108,7 @@
107108
"@chromatic-com/storybook": "^4.1.3",
108109
"@hookform/devtools": "^4.3.1",
109110
"@jedmao/location": "^3.0.0",
110-
"@playwright/test": "^1.47.0",
111+
"@playwright/test": "^1.57.0",
111112
"@storybook/addon-docs": "^10.1.4",
112113
"@storybook/addon-links": "^10.1.4",
113114
"@storybook/addon-styling-webpack": "^3.0.0",

packages/app/playwright.config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export default defineConfig({
1919
reporter: [
2020
['html'],
2121
['json', { outputFile: 'test-results/results.json' }],
22-
...(process.env.CI ? [['github', {}] as const] : []),
22+
...(process.env.CI
23+
? [['github'] as const, ['list'] as const]
24+
: [['list'] as const]),
2325
],
2426
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2527
use: {
@@ -34,7 +36,7 @@ export default defineConfig({
3436
},
3537

3638
/* Global test timeout - CI needs more time than local */
37-
timeout: 45 * 1000,
39+
timeout: 60 * 1000,
3840

3941
/* Configure projects for different test environments */
4042
projects: [
@@ -48,8 +50,9 @@ export default defineConfig({
4850

4951
/* Run your local dev server before starting the tests */
5052
webServer: {
51-
command:
52-
'NEXT_PUBLIC_IS_LOCAL_MODE=true NEXT_TELEMETRY_DISABLED=1 PORT=8081 yarn run dev',
53+
command: process.env.CI
54+
? 'NEXT_PUBLIC_IS_LOCAL_MODE=true yarn build && NEXT_PUBLIC_IS_LOCAL_MODE=true PORT=8081 yarn start'
55+
: 'NEXT_PUBLIC_IS_LOCAL_MODE=true NEXT_TELEMETRY_DISABLED=1 PORT=8081 yarn run dev',
5356
port: 8081,
5457
reuseExistingServer: !process.env.CI,
5558
timeout: 180 * 1000,

packages/app/tests/e2e/README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# End-to-End Testing
22

3-
This directory contains Playwright-based end-to-end tests for the HyperDX application. The tests are organized into core functionality and feature-specific test suites.
3+
This directory contains Playwright-based end-to-end tests for the HyperDX
4+
application. The tests are organized into core functionality and
5+
feature-specific test suites.
46

57
## Prerequisites
68

@@ -47,7 +49,9 @@ cd packages/app && yarn test:e2e --grep "@dashboard"
4749

4850
### Local Mode vs Full Server
4951

50-
Tests tagged with `@local-mode` can run against the local development server without external dependencies. The test configuration automatically starts a local development server with `NEXT_PUBLIC_IS_LOCAL_MODE=true`.
52+
Tests tagged with `@local-mode` can run against the local development server
53+
without external dependencies. The test configuration automatically starts a
54+
local development server with `NEXT_PUBLIC_IS_LOCAL_MODE=true`.
5155

5256
## Test Organization
5357

@@ -87,6 +91,15 @@ Run tests in debug mode with browser developer tools:
8791
yarn test:e2e:debug
8892
```
8993

94+
### CI Mode
95+
96+
Run tests in ci mode, which runs it in a docker container and environment
97+
similar to how it runs inside of Github Actions
98+
99+
```bash
100+
yarn test:e2e:ci
101+
```
102+
90103
### Single Test Debugging
91104

92105
To debug a specific test file:
@@ -114,6 +127,7 @@ yarn playwright show-report
114127
```
115128

116129
The report includes:
130+
117131
- Test execution timeline
118132
- Screenshots of failures
119133
- Video recordings of failed tests
@@ -122,6 +136,7 @@ The report includes:
122136
### Test Results
123137

124138
Test artifacts are stored in:
139+
125140
- `test-results/` - Screenshots, videos, and traces for failed tests
126141
- `playwright-report/` - HTML report files
127142

@@ -138,7 +153,8 @@ yarn playwright show-trace test-results/[test-name]/trace.zip
138153
The test configuration is defined in `playwright.config.ts`:
139154

140155
- **Base URL**: `http://localhost:8080` (configurable via `PLAYWRIGHT_BASE_URL`)
141-
- **Test Timeout**: 60 seconds (increased from default 30s to reduce flaky test failures)
156+
- **Test Timeout**: 60 seconds (increased from default 30s to reduce flaky test
157+
failures)
142158
- **Retries**: 1 retry locally, 2 on CI
143159
- **Workers**: Undefined (uses Playwright defaults)
144160
- **Screenshots**: Captured on failure only
@@ -152,6 +168,7 @@ The test configuration is defined in `playwright.config.ts`:
152168
### Writing Tests
153169

154170
Tests use the extended base test from `utils/base-test.ts` which provides:
171+
155172
- Automatic handling of connection/sources
156173
- Tanstack Query devtools management
157174
- Network idle waiting after navigation
@@ -169,21 +186,25 @@ Tests use the extended base test from `utils/base-test.ts` which provides:
169186
### Server Connection Issues
170187

171188
If tests fail with connection errors:
189+
172190
1. Ensure no other services are running on port 8080
173191
2. Check that the development server starts successfully
174192
3. Verify environment variables are properly configured
175193

176194
### Flaky Tests
177195

178196
For intermittent failures:
197+
179198
1. Check the HTML report for timing issues
180199
2. Review network logs for failed requests
181-
3. Consider if individual test steps need longer wait times (global timeout is now 60s)
200+
3. Consider if individual test steps need longer wait times (global timeout is
201+
now 60s)
182202
4. Use the trace viewer to analyze test execution
183203

184204
### CI/CD Integration
185205

186206
Tests are configured to run in CI environments with:
207+
187208
- 60-second test timeout (same as local)
188209
- Multiple retry attempts (2 retries on CI vs 1 locally)
189210
- Artifact collection for failed tests

scripts/test-e2e-ci.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
# Run E2E tests in Docker with exact CI environment
3+
# This replicates the GitHub Actions CI environment locally for debugging
4+
5+
set -e
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
9+
10+
echo "Running E2E tests in CI Docker environment..."
11+
echo "Repository root: $REPO_ROOT"
12+
13+
docker run --rm \
14+
-v "$REPO_ROOT:/workspace" \
15+
-w /workspace \
16+
-e CI=true \
17+
mcr.microsoft.com/playwright:v1.57.0-jammy \
18+
bash -c '
19+
# Clean all build artifacts and dependencies
20+
rm -rf packages/app/.next packages/common-utils/dist node_modules packages/*/node_modules .yarn/cache
21+
22+
# Fresh install
23+
corepack enable
24+
yarn install
25+
26+
# Build in production mode
27+
npx nx run-many -t ci:build
28+
29+
# Run tests
30+
cd packages/app
31+
yarn test:e2e
32+
33+
# Fix permissions so host can read results
34+
chmod -R 777 test-results playwright-report 2>/dev/null || true
35+
'
36+
37+
echo "Done! Check packages/app/test-results/ for results"

yarn.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4268,7 +4268,7 @@ __metadata:
42684268
"@mantine/notifications": "npm:^7.17.8"
42694269
"@mantine/spotlight": "npm:^7.17.8"
42704270
"@microsoft/fetch-event-source": "npm:^2.0.1"
4271-
"@playwright/test": "npm:^1.47.0"
4271+
"@playwright/test": "npm:^1.57.0"
42724272
"@storybook/addon-docs": "npm:^10.1.4"
42734273
"@storybook/addon-links": "npm:^10.1.4"
42744274
"@storybook/addon-styling-webpack": "npm:^3.0.0"
@@ -7719,14 +7719,14 @@ __metadata:
77197719
languageName: node
77207720
linkType: hard
77217721

7722-
"@playwright/test@npm:^1.47.0":
7723-
version: 1.55.0
7724-
resolution: "@playwright/test@npm:1.55.0"
7722+
"@playwright/test@npm:^1.57.0":
7723+
version: 1.57.0
7724+
resolution: "@playwright/test@npm:1.57.0"
77257725
dependencies:
7726-
playwright: "npm:1.55.0"
7726+
playwright: "npm:1.57.0"
77277727
bin:
77287728
playwright: cli.js
7729-
checksum: 10c0/e68b59cd8271f1b57c0649fc0562ab2d5f6bba8c3653dd7bd52ca1338dc380fde34588d0254e3cd3f0f2b20af04a80dfb080419ceb7475990bb2fc4d8c474984
7729+
checksum: 10c0/35ba4b28be72bf0a53e33dbb11c6cff848fb9a37f49e893ce63a90675b5291ec29a1ba82c8a3b043abaead129400f0589623e9ace2e6a1c8eaa409721ecc3774
77307730
languageName: node
77317731
linkType: hard
77327732

@@ -22637,27 +22637,27 @@ __metadata:
2263722637
languageName: node
2263822638
linkType: hard
2263922639

22640-
"playwright-core@npm:1.55.0":
22641-
version: 1.55.0
22642-
resolution: "playwright-core@npm:1.55.0"
22640+
"playwright-core@npm:1.57.0":
22641+
version: 1.57.0
22642+
resolution: "playwright-core@npm:1.57.0"
2264322643
bin:
2264422644
playwright-core: cli.js
22645-
checksum: 10c0/c39d6aa30e7a4e73965942ca5e13405ae05c9cb49f755a35f04248c864c0b24cf662d9767f1797b3ec48d1cf4e54774dce4a19c16534bd5cfd2aa3da81c9dc3a
22645+
checksum: 10c0/798e35d83bf48419a8c73de20bb94d68be5dde68de23f95d80a0ebe401e3b83e29e3e84aea7894d67fa6c79d2d3d40cc5bcde3e166f657ce50987aaa2421b6a9
2264622646
languageName: node
2264722647
linkType: hard
2264822648

22649-
"playwright@npm:1.55.0":
22650-
version: 1.55.0
22651-
resolution: "playwright@npm:1.55.0"
22649+
"playwright@npm:1.57.0":
22650+
version: 1.57.0
22651+
resolution: "playwright@npm:1.57.0"
2265222652
dependencies:
2265322653
fsevents: "npm:2.3.2"
22654-
playwright-core: "npm:1.55.0"
22654+
playwright-core: "npm:1.57.0"
2265522655
dependenciesMeta:
2265622656
fsevents:
2265722657
optional: true
2265822658
bin:
2265922659
playwright: cli.js
22660-
checksum: 10c0/51605b7e57a5650e57972c5fdfc09d7a9934cca1cbee5beacca716fa801e25cb5bb7c1663de90c22b300fde884e5545a2b13a0505a93270b660687791c478304
22660+
checksum: 10c0/ab03c99a67b835bdea9059f516ad3b6e42c21025f9adaa161a4ef6bc7ca716dcba476d287140bb240d06126eb23f889a8933b8f5f1f1a56b80659d92d1358899
2266122661
languageName: node
2266222662
linkType: hard
2266322663

0 commit comments

Comments
 (0)