Skip to content

Commit 02d982e

Browse files
committed
add test variants (cf, node, bun)
1 parent 3cd89a4 commit 02d982e

16 files changed

Lines changed: 161 additions & 75 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,9 @@ jobs:
930930
with:
931931
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
932932
- name: Set up Bun
933-
if: contains(fromJSON('["node-exports-test-app","nextjs-16-bun", "elysia-bun"]'), matrix.test-application)
933+
if:
934+
contains(fromJSON('["node-exports-test-app","nextjs-16-bun", "elysia-bun", "hono-4"]'),
935+
matrix.test-application)
934936
uses: oven-sh/setup-bun@v2
935937
- name: Set up AWS SAM
936938
if: matrix.test-application == 'aws-serverless'

dev-packages/e2e-tests/test-applications/hono-4-cf/package.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore renamed to dev-packages/e2e-tests/test-applications/hono-4/.gitignore

File renamed without changes.

dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc renamed to dev-packages/e2e-tests/test-applications/hono-4/.npmrc

File renamed without changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "hono-4",
3+
"type": "module",
4+
"version": "0.0.0",
5+
"private": true,
6+
"scripts": {
7+
"dev:cf": "wrangler dev --var \"E2E_TEST_DSN:$E2E_TEST_DSN\" --log-level=$(test $CI && echo 'none' || echo 'log')",
8+
"dev:node": "node --import tsx/esm --import @sentry/node/preload src/entry.node.ts",
9+
"dev:bun": "bun src/entry.bun.ts",
10+
"build": "wrangler deploy --dry-run",
11+
"test:build": "pnpm install && pnpm build",
12+
"test:assert": "TEST_ENV=production playwright test"
13+
},
14+
"dependencies": {
15+
"@sentry/hono": "latest || *",
16+
"@sentry/node": "latest || *",
17+
"@hono/node-server": "^1.19.10",
18+
"hono": "^4.12.14"
19+
},
20+
"devDependencies": {
21+
"@playwright/test": "~1.56.0",
22+
"@cloudflare/workers-types": "^4.20240725.0",
23+
"@sentry-internal/test-utils": "link:../../../test-utils",
24+
"tsx": "^4.20.3",
25+
"typescript": "^5.5.2",
26+
"wrangler": "^4.61.0"
27+
},
28+
"volta": {
29+
"extends": "../../package.json"
30+
},
31+
"sentryTest": {
32+
"variants": [
33+
{
34+
"assert-command": "RUNTIME=node pnpm test:assert",
35+
"label": "hono-4 (node)"
36+
},
37+
{
38+
"assert-command": "RUNTIME=bun pnpm test:assert",
39+
"label": "hono-4 (bun)"
40+
}
41+
]
42+
}
43+
}

dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts renamed to dev-packages/e2e-tests/test-applications/hono-4/playwright.config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
22

3+
type Runtime = 'cloudflare' | 'node' | 'bun';
4+
5+
const RUNTIME = (process.env.RUNTIME || 'cloudflare') as Runtime;
6+
37
const testEnv = process.env.TEST_ENV;
48

59
if (!testEnv) {
@@ -8,9 +12,15 @@ if (!testEnv) {
812

913
const APP_PORT = 38787;
1014

15+
const startCommands: Record<Runtime, string> = {
16+
cloudflare: `pnpm dev:cf --port ${APP_PORT}`,
17+
node: `pnpm dev:node`,
18+
bun: `pnpm dev:bun`,
19+
};
20+
1121
const config = getPlaywrightConfig(
1222
{
13-
startCommand: `pnpm dev --port ${APP_PORT}`,
23+
startCommand: startCommands[RUNTIME],
1424
port: APP_PORT,
1525
},
1626
{
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Hono } from 'hono';
2+
import { sentry } from '@sentry/hono/bun';
3+
import { addRoutes } from './routes';
4+
5+
const app = new Hono<{ Bindings: { E2E_TEST_DSN: string } }>();
6+
7+
app.use(
8+
// @ts-expect-error - Env is not yet in type
9+
sentry(app, {
10+
dsn: process.env.E2E_TEST_DSN,
11+
environment: 'qa',
12+
tracesSampleRate: 1.0,
13+
tunnel: 'http://localhost:3031/',
14+
}),
15+
);
16+
17+
addRoutes(app);
18+
19+
const port = Number(process.env.PORT || 38787);
20+
21+
export default {
22+
port,
23+
fetch: app.fetch,
24+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Hono } from 'hono';
2+
import { sentry } from '@sentry/hono/cloudflare';
3+
import { addRoutes } from './routes';
4+
5+
const app = new Hono<{ Bindings: { E2E_TEST_DSN: string } }>();
6+
7+
app.use(
8+
sentry(app, env => ({
9+
dsn: env.E2E_TEST_DSN,
10+
environment: 'qa',
11+
tracesSampleRate: 1.0,
12+
tunnel: 'http://localhost:3031/',
13+
})),
14+
);
15+
16+
addRoutes(app);
17+
18+
export default app;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Hono } from 'hono';
2+
import { sentry } from '@sentry/hono/node';
3+
import { serve } from '@hono/node-server';
4+
import { addRoutes } from './routes';
5+
6+
const app = new Hono<{ Bindings: { E2E_TEST_DSN: string } }>();
7+
8+
app.use(
9+
// @ts-expect-error - Env is not yet in type
10+
sentry(app, {
11+
dsn: process.env.E2E_TEST_DSN,
12+
environment: 'qa',
13+
tracesSampleRate: 1.0,
14+
tunnel: 'http://localhost:3031/',
15+
}),
16+
);
17+
18+
addRoutes(app);
19+
20+
const port = Number(process.env.PORT || 38787);
21+
22+
serve({ fetch: app.fetch, port }, () => {
23+
console.log(`Hono (Node) listening on port ${port}`);
24+
});

0 commit comments

Comments
 (0)