Skip to content

Commit fee7ad6

Browse files
committed
test(e2e): Add astro-7-static E2E app
Duplicates `astro-7` so the static trace lifecycle keeps E2E coverage once the Astro apps move to span streaming.
1 parent 19a3913 commit fee7ad6

40 files changed

Lines changed: 1635 additions & 0 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# build output
2+
dist/
3+
4+
# generated types
5+
.astro/
6+
7+
# dependencies
8+
node_modules/
9+
10+
# logs
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store
22+
23+
# jetbrains setting folder
24+
.idea/
25+
26+
test-results
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sentry from '@sentry/astro';
2+
// @ts-check
3+
import { defineConfig } from 'astro/config';
4+
5+
import node from '@astrojs/node';
6+
7+
// https://astro.build/config
8+
export default defineConfig({
9+
integrations: [
10+
sentry({
11+
debug: true,
12+
sourcemaps: {
13+
disable: true,
14+
},
15+
}),
16+
],
17+
output: 'server',
18+
security: {
19+
allowedDomains: [{ hostname: 'localhost' }],
20+
},
21+
adapter: node({
22+
mode: 'standalone',
23+
}),
24+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
db:
3+
image: mysql:8.0
4+
restart: always
5+
container_name: e2e-tests-astro-7-static-mysql
6+
# The `mysql` 2.x driver doesn't speak MySQL 8's default
7+
# `caching_sha2_password` auth, so force the legacy plugin.
8+
command: ['--default-authentication-plugin=mysql_native_password']
9+
ports:
10+
- '3306:3306'
11+
environment:
12+
MYSQL_ROOT_PASSWORD: docker
13+
healthcheck:
14+
test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 -uroot -pdocker']
15+
interval: 2s
16+
timeout: 3s
17+
retries: 30
18+
start_period: 10s
19+
20+
redis:
21+
image: redis:7
22+
restart: always
23+
container_name: e2e-tests-astro-7-static-redis
24+
ports:
25+
- '6379:6379'
26+
healthcheck:
27+
test: ['CMD', 'redis-cli', 'ping']
28+
interval: 2s
29+
timeout: 3s
30+
retries: 30
31+
start_period: 5s
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { execSync } from 'child_process';
2+
import { dirname } from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
7+
export default async function globalSetup() {
8+
// Start MySQL + Redis via Docker Compose. `--wait` blocks until the
9+
// healthchecks in docker-compose.yml pass, so the app can connect immediately.
10+
execSync('docker compose up -d --wait', {
11+
cwd: __dirname,
12+
stdio: 'inherit',
13+
});
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { execSync } from 'child_process';
2+
import { dirname } from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
7+
export default async function globalTeardown() {
8+
execSync('docker compose down --volumes', {
9+
cwd: __dirname,
10+
stdio: 'inherit',
11+
});
12+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "astro-7-static",
3+
"type": "module",
4+
"version": "0.0.1",
5+
"scripts": {
6+
"dev": "astro dev",
7+
"build": "astro build",
8+
"preview": "astro preview",
9+
"astro": "astro",
10+
"start": "node ./dist/server/entry.mjs",
11+
"test:build": "pnpm install && pnpm build",
12+
"test:assert": "pnpm test:prod && pnpm test:dev",
13+
"test:prod": "TEST_ENV=production playwright test",
14+
"test:dev": "TEST_ENV=development playwright test db"
15+
},
16+
"//": "Need to use ioredis 5.10.1 because that's the last version before they support tracing channels",
17+
"dependencies": {
18+
"@astrojs/node": "^11.1.4",
19+
"@playwright/test": "~1.56.0",
20+
"@sentry-internal/test-utils": "link:../../../test-utils",
21+
"@sentry/astro": "file:../../packed/sentry-astro-packed.tgz",
22+
"astro": "^7.2.4",
23+
"ioredis": "5.10.1",
24+
"mysql": "^2.18.1"
25+
},
26+
"volta": {
27+
"node": "22.22.0",
28+
"extends": "../../package.json"
29+
},
30+
"sentryTest": {
31+
"optional": true
32+
}
33+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const testEnv = process.env.TEST_ENV;
4+
5+
if (!testEnv) {
6+
throw new Error('No test env defined');
7+
}
8+
9+
// `astro dev` ignores PORT, so the port goes on the command.
10+
const config = getPlaywrightConfig({
11+
startCommand: testEnv === 'development' ? 'pnpm dev --port 3030' : 'pnpm start',
12+
});
13+
14+
export default {
15+
...config,
16+
globalSetup: './global-setup.mjs',
17+
globalTeardown: './global-teardown.mjs',
18+
};
Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as Sentry from '@sentry/astro';
2+
3+
Sentry.init({
4+
traceLifecycle: 'static',
5+
dsn: import.meta.env.PUBLIC_E2E_TEST_DSN,
6+
environment: 'qa',
7+
tracesSampleRate: 1.0,
8+
tunnel: 'http://localhost:3031/', // proxy server
9+
integrations: [
10+
Sentry.browserTracingIntegration({
11+
beforeStartSpan: opts => {
12+
if (opts.name.startsWith('/blog/')) {
13+
return {
14+
...opts,
15+
name: window.location.pathname,
16+
};
17+
}
18+
return opts;
19+
},
20+
}),
21+
],
22+
debug: true,
23+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Sentry from '@sentry/astro';
2+
3+
Sentry.init({
4+
traceLifecycle: 'static',
5+
dsn: import.meta.env.PUBLIC_E2E_TEST_DSN,
6+
environment: 'qa',
7+
tracesSampleRate: 1.0,
8+
tunnel: 'http://localhost:3031/', // proxy server
9+
debug: true,
10+
});

0 commit comments

Comments
 (0)