8000 test(solidstart): Add solidstart e2e test app (#12873) · mcous/sentry-javascript@4852dc7 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 4852dc7

Browse files
authored
test(solidstart): Add solidstart e2e test app (getsentry#12873)
For now this only tests client side errors. It also doesn't use the solidrouter integration yet because it fails to resolve the `@sentry/solidstart/solidrouter` import properly in our repo. I have yet to figure out what exactly is causing this (my guess is some pnpm shenanigans). I couldn't reproduce this in a sample app outside of our repo yet. Closes: getsentry#12547
1 parent 9bb9c99 commit 4852dc7

21 files changed

+456
-3
lines changed

biome.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
".angular/**",
4444
"angular.json",
4545
"ember/instance-initializers/**",
46-
"ember/types.d.ts"
46+
"ember/types.d.ts",
47+
".output",
48+
".vinxi"
4749
]
4850
},
4951
"files": {

dev-packages/e2e-tests/test-applications/solid-solidrouter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"dependencies": {
2929
"@solidjs/router": "^0.13.5",
30-
"solid-js": "^1.8.11",
30+
"solid-js": "^1.8.18",
3131
"@sentry/solid": "latest || *"
3232
}
3333
}

dev-packages/e2e-tests/test-applications/solid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"vite-plugin-solid": "^2.8.2"
2727
},
2828
"dependencies": {
29-
"solid-js": "^1.8.11",
29+
"solid-js": "^1.8.18",
3030
"@sentry/solid": "latest || *"
3131
}
3232
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
dist
3+
.solid
4+
.output
5+
.vercel
6+
.netlify
7+
.vinxi
8+
9+
# Environment
10+
.env
11+
.env*.local
12+
13+
# dependencies
14+
/node_modules
15+
/.pnp
16+
.pnp.js
17+
18+
# IDEs and editors
19+
/.idea
20+
.project
21+
.classpath
22+
*.launch
23+
.settings/
24+
25+
# Temp
26+
gitignore
27+
28+
# testing
29+
/coverage
30+
31+
# misc
32+
.DS_Store
33+
.env.local
34+
.env.development.local
35+
.env.test.local
36+
.env.production.local
37+
38+
npm-debug.log*
39+
yarn-debug.log*
40+
yarn-error.log*
41+
42+
/test-results/
43+
/playwright-report/
44+
/playwright/.cache/
45+
46+
!*.d.ts
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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SolidStart
2+
3+
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);
4+
5+
## Creating a project
6+
7+
```bash
8+
# create a new project in the current directory
9+
npm init solid@latest
10+
11+
# create a new project in my-app
12+
npm init solid@latest my-app
13+
```
14+
15+
## Developing
16+
17+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a
18+
development server:
19+
20+
```bash
21+
npm run dev
22+
23+
# or start the server and open the app in a new browser tab
24+
npm run dev -- --open
25+
```
26+
27+
## Building
28+
29+
Solid apps are built with _presets_, which optimise your project for deployment to different environments.
30+
31+
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different preset, add
32+
it to the `devDependencies` in `package.json` and specify in your `app.config.js`.
33+
34+
## Testing
35+
36+
Tests are written with `vitest`, `@solidjs/testing-library` and `@testing-library/jest-dom` to extend expect with some
37+
helpful custom matchers.
38+
39+
To run them, simply start:
40+
41+
```sh
42+
npm test
43+
```
44+
45+
## This project was created with the [Solid CLI](https://solid-cli.netlify.app)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { defineConfig } from '@solidjs/start/config';
2+
3+
export default defineConfig({});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "example-with-vitest",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"clean": "pnpx rimraf node_modules pnpm-lock.yaml .vinxi .output",
6+
"dev": "NODE_OPTIONS='--import ./src/instrument.server.mjs' vinxi dev",
7+
"build": "vinxi build",
8+
"preview": "HOST=localhost PORT=3030 NODE_OPTIONS='--import ./src/instrument.server.mjs' vinxi start",
9+
"test:prod": "TEST_ENV=production playwright test",
10+
"test:build": "pnpm install && npx playwright install && pnpm build",
11+
"test:assert": "pnpm test:prod"
12+
},
13+
"type": "module",
14+
"dependencies": {
15+
"@sentry/solidstart": "latest || *"
16+
},
17+
"devDependencies": {
18+
"@playwright/test": "^1.44.1",
19+
"@solidjs/meta": "^0.29.4",
20+
"@solidjs/router": "^0.13.4",
21+
"@solidjs/start": "^1.0.2",
22+
"@solidjs/testing-library": "^0.8.7",
23+
"@testing-library/jest-dom": "^6.4.2",
24+
"@testing-library/user-event": "^14.5.2",
25+
"@vitest/ui": "^1.5.0",
26+
"jsdom": "^24.0.0",
27+
"solid-js": "1.8.17",
28+
"typescript": "^5.4.5",
29+
"vinxi": "^0.3.12",
30+
"vite": "^5.2.8",
31+
&q 1241 uot;vite-plugin-solid": "^2.10.2",
32+
"vitest": "^1.5.0"
33+
}
34+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: 'pnpm preview',
5+
port: 3030,
6+
});
7+
8+
export default config;
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { MetaProvider, Title } from '@solidjs/meta';
2+
import { Router } from '@solidjs/router';
3+
import { FileRoutes } from '@solidjs/start/router';
4+
import { Suspense } from 'solid-js';
5+
6+
export default function App() {
7+
return (
8+
<Router
9+
root={props => (
10+
<MetaProvider>
11+
<Title>SolidStart - with Vitest</Title>
12+
<Suspense>{props.children}</Suspense>
13+
</MetaProvider>
14+
)}
15+
>
16+
<FileRoutes />
17+
</Router>
18+
);
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @refresh reload
2+
import * as Sentry from '@sentry/solidstart';
3+
import { StartClient, mount } from '@solidjs/start/client';
4+
5+
Sentry.init({
6+
// We can't use env variables here, seems like they are stripped
7+
// out in production builds.
8+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
9+
environment: 'qa', // dynamic sampling bias to keep transactions
10+
integrations: [Sentry.browserTracingIntegration()],
11+
tunnel: 'http://localhost:3031/', // proxy server
12+
// Performance Monitoring
13+
tracesSampleRate: 1.0, // Capture 100% of the transactions
14+
});
15+
16+
mount(() => <StartClient />, document.getElementById('app')!);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @refresh reload
2+
import { StartServer, createHandler } from '@solidjs/start/server';
3+
4+
export default createHandler(() => (
5+
<StartServer
6+
document={({ assets, children, scripts }) => (
7+
<html lang="en">
8+
<head>
9+
<meta charset="utf-8" />
10+
<meta name="viewport" content="width=device-width, initial-scale=1" />
11+
<link rel="icon" href="/favicon.ico" />
12+
{assets}
13+
</head>
14+
<body>
15+
<div id="app">{children}</div>
16+
{scripts}
17+
</body>
18+
</html>
19+
)}
20+
/>
21+
));
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as Sentry from '@sentry/solidstart';
2+
3+
Sentry.init({
4+
dsn: process.env.E2E_TEST_DSN,
5+
environment: 'qa', // dynamic sampling bias to keep transactions
6+
tracesSampleRate: 1.0, // Capture 100% of the transactions
7+
tunnel: 'http://localhost:3031/', // proxy server
8+
});
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import * as Sentry from '@sentry/solidstart';
2+
import type { ParentProps } from 'solid-js';
3+
import { ErrorBoundary, createSignal, onMount } from 'solid-js';
4+
5+
const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary);
6+
7+
const [count, setCount] = createSignal(1);
8+
const [caughtError, setCaughtError] = createSignal(false);
9+
10+
export default function ClientErrorPage() {
11+
return (
12+
<SampleErrorBoundary>
13+
{caughtError() && (
14+
<Throw error={`Error ${count()} thrown from Sentry ErrorBoundary in Solid Start E2E test app`} />
15+
)}
16+
<section class="bg-gray-100 text-gray-700 p-8">
17+
<div class="flex flex-col items-start space-x-2">
18+
<button
19+
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer"
20+
id="caughtErrorBtn"
21+
onClick={() => setCaughtError(true)}
22+
>
23+
Throw caught error
24+
</button>
25+
</div>
26+
<div class="flex flex-col items-start space-x-2">
27+
<button
28+
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer"
29+
id="errorBtn"
30+
onClick={() => {
31+
throw new Error('Error thrown from Solid Start E2E test app');
32+
}}
33+
>
34+
Throw uncaught error
35+
</button>
36+
</div>
37+
</section>
38+
</SampleErrorBoundary>
39+
);
40+
}
41+
42+
function Throw(props: { error: string }) {
43+
onMount(() => {
44+
throw new Error(props.error);
45+
});
46+
return null;
47+
}
48+
49+
function SampleErrorBoundary(props: ParentProps) {
50+
return (
51+
<SentryErrorBoundary
52+
fallback={(error, reset) => (
53+
<section class="bg-gray-100 text-gray-700 p-8">
54+
<h1 class="text-2xl font-bold">Error Boundary Fallback</h1>
55+
<div class="flex items-center space-x-2 mb-4">
56+
<code>{error.message}</code>
57+
</div>
58+
<button
59+
id="errorBoundaryResetBtn"
60+
class="border rounded-lg px-2 border-gray-900"
61+
onClick={() => {
62+
setCount(count() + 1);
63+
setCaughtError(false);
64+
reset();
65+
}}
66+
>
67+
Reset
68+
</button>
69+
</section>
70+
)}
71+
>
72+
{props.children}
73+
</SentryErrorBoundary>
74+
);
75+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { A } from '@solidjs/router';
2+
3+
export default function Home() {
4+
return (
5+
<>
6+
<h1>Welcome to Solid Start</h1>
7+
<p>
8+
Visit <a href="https://docs.solidjs.com/solid-start">docs.solidjs.com/solid-start</a> to read the documentation
9+
</p>
10+
<ul>
11+
<li>
12+
<A href="/client-error">Client error</A>
13+
</li>
14+
</ul>
15+
</>
16+
);
17+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { startEventProxyServer } from '@sentry-internal/test-utils';
2+
3+
startEventProxyServer({
4+
port: 3031,
5+
proxyServerName: 'solidstart',
6+
});

0 commit comments

Comments
 (0)
0