Skip to content

Commit 72b0a18

Browse files
authored
test(nextjs): Add e2e test for orpc (#16462)
Basic e2e for making sure tracing looks ok for orpc calls
1 parent ae76a85 commit 72b0a18

26 files changed

+584
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
38+
!*.d.ts
39+
40+
# Sentry
41+
.sentryclirc
42+
43+
.vscode
44+
45+
test-results
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sentry:registry=http://127.0.0.1:4873
2+
@sentry-internal:registry=http://127.0.0.1:4873
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import("next").NextConfig} */
2+
const config = {};
3+
4+
import { withSentryConfig } from '@sentry/nextjs';
5+
6+
export default withSentryConfig(config, {
7+
disableLogger: true,
8+
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "next-orpc",
3+
"version": "0.1.0",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"build": "next build",
8+
"dev": "next dev -p 3030",
9+
"start": "next start -p 3030",
10+
"clean": "npx rimraf node_modules pnpm-lock.yaml",
11+
"test:prod": "TEST_ENV=production playwright test",
12+
"test:dev": "TEST_ENV=development playwright test",
13+
"test:build": "pnpm install && pnpm build",
14+
"test:build-canary": "pnpm install && pnpm add next@canary && pnpm add react@beta && pnpm add react-dom@beta && pnpm build",
15+
"test:build-latest": "pnpm install && pnpm add next@rc && pnpm add react@beta && pnpm add react-dom@beta && pnpm build",
16+
"test:assert": "pnpm test:prod && pnpm test:dev"
17+
},
18+
"dependencies": {
19+
"@sentry/nextjs": "latest || *",
20+
"@orpc/server": "latest",
21+
"@orpc/client": "latest",
22+
"next": "14.2.29",
23+
"react": "18.3.1",
24+
"react-dom": "18.3.1",
25+
"server-only": "^0.0.1"
26+
},
27+
"devDependencies": {
28+
"@playwright/test": "~1.50.0",
29+
"@sentry-internal/test-utils": "link:../../../test-utils",
30+
"@types/eslint": "^8.56.10",
31+
"@types/node": "^18.19.1",
32+
"@types/react": "18.3.1",
33+
"@types/react-dom": "^18.3.0",
34+
"@typescript-eslint/eslint-plugin": "^8.1.0",
35+
"@typescript-eslint/parser": "^8.1.0",
36+
"eslint": "^8.57.0",
37+
"eslint-config-next": "^14.2.4",
38+
"postcss": "^8.4.39",
39+
"prettier": "^3.3.2",
40+
"typescript": "^5.5.3"
41+
},
42+
"volta": {
43+
"extends": "../../package.json"
44+
}
45+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
const testEnv = process.env.TEST_ENV;
3+
4+
if (!testEnv) {
5+
throw new Error('No test env defined');
6+
}
7+
8+
const config = getPlaywrightConfig(
9+
{
10+
startCommand: testEnv === 'development' ? 'pnpm next dev -p 3030' : 'pnpm next start -p 3030',
11+
port: 3030,
12+
},
13+
{
14+
// This comes with the risk of tests leaking into each other but the tests run quite slow so we should parallelize
15+
workers: '100%',
16+
},
17+
);
18+
19+
export default config;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
2+
// The config you add here will be used whenever one of the edge features is loaded.
3+
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
4+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
5+
6+
import * as Sentry from '@sentry/nextjs';
7+
8+
Sentry.init({
9+
environment: 'qa', // dynamic sampling bias to keep transactions
10+
dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN,
11+
tunnel: `http://localhost:3031/`, // proxy server
12+
tracesSampleRate: 1.0,
13+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as Sentry from '@sentry/nextjs';
2+
3+
Sentry.init({
4+
environment: 'qa', // dynamic sampling bias to keep transactions
5+
dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN,
6+
tunnel: `http://localhost:3031/`, // proxy server
7+
tracesSampleRate: 1.0,
8+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { FindPlanet } from '~/components/FindPlanet';
2+
3+
export default async function ClientErrorPage() {
4+
return (
5+
<main>
6+
<FindPlanet withError />
7+
</main>
8+
);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { FindPlanet } from '~/components/FindPlanet';
2+
3+
export default async function ClientPage() {
4+
return (
5+
<main>
6+
<FindPlanet />
7+
</main>
8+
);
9+
}

0 commit comments

Comments
 (0)