-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(solidstart): Add solidstart e2e test app (#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: #12547
- Loading branch information
1 parent
9bb9c99
commit 4852dc7
Showing
21 changed files
with
456 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
dev-packages/e2e-tests/test-applications/solidstart/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
dist | ||
.solid | ||
.output | ||
.vercel | ||
.netlify | ||
.vinxi | ||
|
||
# Environment | ||
.env | ||
.env*.local | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
*.launch | ||
.settings/ | ||
|
||
# Temp | ||
gitignore | ||
|
||
# testing | ||
/coverage | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
|
||
!*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@sentry:registry=http://127.0.0.1:4873 | ||
@sentry-internal:registry=http://127.0.0.1:4873 |
45 changes: 45 additions & 0 deletions
45
dev-packages/e2e-tests/test-applications/solidstart/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SolidStart | ||
|
||
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com); | ||
|
||
## Creating a project | ||
|
||
```bash | ||
# create a new project in the current directory | ||
npm init solid@latest | ||
|
||
# create a new project in my-app | ||
npm init solid@latest my-app | ||
``` | ||
|
||
## Developing | ||
|
||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a | ||
development server: | ||
|
||
```bash | ||
npm run dev | ||
|
||
# or start the server and open the app in a new browser tab | ||
npm run dev -- --open | ||
``` | ||
|
||
## Building | ||
|
||
Solid apps are built with _presets_, which optimise your project for deployment to different environments. | ||
|
||
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different preset, add | ||
it to the `devDependencies` in `package.json` and specify in your `app.config.js`. | ||
|
||
## Testing | ||
|
||
Tests are written with `vitest`, `@solidjs/testing-library` and `@testing-library/jest-dom` to extend expect with some | ||
helpful custom matchers. | ||
|
||
To run them, simply start: | ||
|
||
```sh | ||
npm test | ||
``` | ||
|
||
## This project was created with the [Solid CLI](https://solid-cli.netlify.app) |
3 changes: 3 additions & 0 deletions
3
dev-packages/e2e-tests/test-applications/solidstart/app.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { defineConfig } from '@solidjs/start/config'; | ||
|
||
export default defineConfig({}); |
34 changes: 34 additions & 0 deletions
34
dev-packages/e2e-tests/test-applications/solidstart/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "example-with-vitest", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"clean": "pnpx rimraf node_modules pnpm-lock.yaml .vinxi .output", | ||
"dev": "NODE_OPTIONS='--import ./src/instrument.server.mjs' vinxi dev", | ||
"build": "vinxi build", | ||
"preview": "HOST=localhost PORT=3030 NODE_OPTIONS='--import ./src/instrument.server.mjs' vinxi start", | ||
"test:prod": "TEST_ENV=production playwright test", | ||
"test:build": "pnpm install && npx playwright install && pnpm build", | ||
"test:assert": "pnpm test:prod" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"@sentry/solidstart": "latest || *" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.44.1", | ||
"@solidjs/meta": "^0.29.4", | ||
"@solidjs/router": "^0.13.4", | ||
"@solidjs/start": "^1.0.2", | ||
"@solidjs/testing-library": "^0.8.7", | ||
"@testing-library/jest-dom": "^6.4.2", | ||
"@testing-library/user-event": "^14.5.2", | ||
"@vitest/ui": "^1.5.0", | ||
"jsdom": "^24.0.0", | ||
"solid-js": "1.8.17", | ||
"typescript": "^5.4.5", | ||
"vinxi": "^0.3.12", | ||
"vite": "^5.2.8", | ||
"vite-plugin-solid": "^2.10.2", | ||
"vitest": "^1.5.0" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
dev-packages/e2e-tests/test-applications/solidstart/playwright.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { getPlaywrightConfig } from '@sentry-internal/test-utils'; | ||
|
||
const config = getPlaywrightConfig({ | ||
startCommand: 'pnpm preview', | ||
port: 3030, | ||
}); | ||
|
||
export default config; |
Binary file added
BIN
+664 Bytes
dev-packages/e2e-tests/test-applications/solidstart/public/favicon.ico
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
dev-packages/e2e-tests/test-applications/solidstart/src/app.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MetaProvider, Title } from '@solidjs/meta'; | ||
import { Router } from '@solidjs/router'; | ||
import { FileRoutes } from '@solidjs/start/router'; | ||
import { Suspense } from 'solid-js'; | ||
|
||
export default function App() { | ||
return ( | ||
<Router | ||
root={props => ( | ||
<MetaProvider> | ||
<Title>SolidStart - with Vitest</Title> | ||
<Suspense>{props.children}</Suspense> | ||
</MetaProvider> | ||
)} | ||
> | ||
<FileRoutes /> | ||
</Router> | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
dev-packages/e2e-tests/test-applications/solidstart/src/entry-client.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @refresh reload | ||
import * as Sentry from '@sentry/solidstart'; | ||
import { StartClient, mount } from '@solidjs/start/client'; | ||
|
||
Sentry.init({ | ||
// We can't use env variables here, seems like they are stripped | ||
// out in production builds. | ||
dsn: 'https://[email protected]/1337', | ||
environment: 'qa', // dynamic sampling bias to keep transactions | ||
integrations: [Sentry.browserTracingIntegration()], | ||
tunnel: 'http://localhost:3031/', // proxy server | ||
// Performance Monitoring | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions | ||
}); | ||
|
||
mount(() => <StartClient />, document.getElementById('app')!); |
21 changes: 21 additions & 0 deletions
21
dev-packages/e2e-tests/test-applications/solidstart/src/entry-server.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// @refresh reload | ||
import { StartServer, createHandler } from '@solidjs/start/server'; | ||
|
||
export default createHandler(() => ( | ||
<StartServer | ||
document={({ assets, children, scripts }) => ( | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
{assets} | ||
</head> | ||
<body> | ||
<div id="app">{children}</div> | ||
{scripts} | ||
</body> | ||
</html> | ||
)} | ||
/> | ||
)); |
8 changes: 8 additions & 0 deletions
8
dev-packages/e2e-tests/test-applications/solidstart/src/instrument.server.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as Sentry from '@sentry/solidstart'; | ||
|
||
Sentry.init({ | ||
dsn: process.env.E2E_TEST_DSN, | ||
environment: 'qa', // dynamic sampling bias to keep transactions | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions | ||
tunnel: 'http://localhost:3031/', // proxy server | ||
}); |
75 changes: 75 additions & 0 deletions
75
dev-packages/e2e-tests/test-applications/solidstart/src/routes/client-error.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import * as Sentry from '@sentry/solidstart'; | ||
import type { ParentProps } from 'solid-js'; | ||
import { ErrorBoundary, createSignal, onMount } from 'solid-js'; | ||
|
||
const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary); | ||
|
||
const [count, setCount] = createSignal(1); | ||
const [caughtError, setCaughtError] = createSignal(false); | ||
|
||
export default function ClientErrorPage() { | ||
return ( | ||
<SampleErrorBoundary> | ||
{caughtError() && ( | ||
<Throw error={`Error ${count()} thrown from Sentry ErrorBoundary in Solid Start E2E test app`} /> | ||
)} | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="caughtErrorBtn" | ||
onClick={() => setCaughtError(true)} | ||
> | ||
Throw caught error | ||
</button> | ||
</div> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="errorBtn" | ||
onClick={() => { | ||
throw new Error('Error thrown from Solid Start E2E test app'); | ||
}} | ||
> | ||
Throw uncaught error | ||
</button> | ||
</div> | ||
</section> | ||
</SampleErrorBoundary> | ||
); | ||
} | ||
|
||
function Throw(props: { error: string }) { | ||
onMount(() => { | ||
throw new Error(props.error); | ||
}); | ||
return null; | ||
} | ||
|
||
function SampleErrorBoundary(props: ParentProps) { | ||
return ( | ||
<SentryErrorBoundary | ||
fallback={(error, reset) => ( | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<h1 class="text-2xl font-bold">Error Boundary Fallback</h1> | ||
<div class="flex items-center space-x-2 mb-4"> | ||
<code>{error.message}</code> | ||
</div> | ||
<button | ||
id="errorBoundaryResetBtn" | ||
class="border rounded-lg px-2 border-gray-900" | ||
onClick={() => { | ||
setCount(count() + 1); | ||
setCaughtError(false); | ||
reset(); | ||
}} | ||
> | ||
Reset | ||
</button> | ||
</section> | ||
)} | ||
> | ||
{props.children} | ||
</SentryErrorBoundary> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
dev-packages/e2e-tests/test-applications/solidstart/src/routes/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { A } from '@solidjs/router'; | ||
|
||
export default function Home() { | ||
return ( | ||
<> | ||
<h1>Welcome to Solid Start</h1> | ||
<p> | ||
Visit <a href="https://docs.solidjs.com/solid-start">docs.solidjs.com/solid-start</a> to read the documentation | ||
</p> | ||
<ul> | ||
<li> | ||
<A href="/client-error">Client error</A> | ||
</li> | ||
</ul> | ||
</> | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/solidstart/start-event-proxy.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { startEventProxyServer } from '@sentry-internal/test-utils'; | ||
|
||
startEventProxyServer({ | ||
port: 3031, | ||
proxyServerName: 'solidstart', | ||
}); |
Oops, something went wrong.