Skip to content

Commit fd57c8d

Browse files
committed
add and finalize tests
1 parent 4d2a9cb commit fd57c8d

File tree

27 files changed

+479
-60
lines changed

27 files changed

+479
-60
lines changed

dev-packages/e2e-tests/test-applications/sveltekit/event-proxy-server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as os from 'os';
66
import * as path from 'path';
77
import * as util from 'util';
88
import * as zlib from 'zlib';
9-
import type { Envelope, EnvelopeItem, Event } from '@sentry/types';
9+
import type { Envelope, EnvelopeItem, Event, SerializedEvent } from '@sentry/types';
1010
import { parseEnvelope } from '@sentry/utils';
1111

1212
const readFile = util.promisify(fs.readFile);
@@ -226,13 +226,13 @@ export function waitForError(
226226

227227
export function waitForTransaction(
228228
proxyServerName: string,
229-
callback: (transactionEvent: Event) => Promise<boolean> | boolean,
230-
): Promise<Event> {
229+
callback: (transactionEvent: SerializedEvent) => Promise<boolean> | boolean,
230+
): Promise<SerializedEvent> {
231231
return new Promise((resolve, reject) => {
232232
waitForEnvelopeItem(proxyServerName, async envelopeItem => {
233233
const [envelopeItemHeader, envelopeItemBody] = envelopeItem;
234-
if (envelopeItemHeader.type === 'transaction' && (await callback(envelopeItemBody as Event))) {
235-
resolve(envelopeItemBody as Event);
234+
if (envelopeItemHeader.type === 'transaction' && (await callback(envelopeItemBody as SerializedEvent))) {
235+
resolve(envelopeItemBody as SerializedEvent);
236236
return true;
237237
}
238238
return false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"@sentry/sveltekit": "latest || *"
1818
},
1919
"devDependencies": {
20-
"@playwright/test": "^1.36.2",
20+
"@playwright/test": "^1.41.1",
2121
"@sentry/types": "latest || *",
2222
"@sentry/utils": "latest || *",
2323
"@sveltejs/adapter-auto": "^2.0.0",
2424
"@sveltejs/adapter-node": "^1.2.4",
25-
"@sveltejs/kit": "^1.5.0",
25+
"@sveltejs/kit": "^1.30.3",
2626
"svelte": "^3.54.0",
2727
"svelte-check": "^3.0.1",
2828
"ts-node": "10.9.1",

dev-packages/e2e-tests/test-applications/sveltekit/playwright.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if (!testEnv) {
88
}
99

1010
const port = 3030;
11+
const eventProxyPort = 3031;
1112

1213
/**
1314
* See https://playwright.dev/docs/test-configuration.
@@ -23,8 +24,9 @@ const config: PlaywrightTestConfig = {
2324
*/
2425
timeout: 10000,
2526
},
27+
workers: 1,
2628
/* Run tests in files in parallel */
27-
fullyParallel: true,
29+
fullyParallel: false,
2830
/* Fail the build on CI if you accidentally left test.only in the source code. */
2931
forbidOnly: !!process.env.CI,
3032
/* `next dev` is incredibly buggy with the app dir */
@@ -61,8 +63,8 @@ const config: PlaywrightTestConfig = {
6163
{
6264
command:
6365
testEnv === 'development'
64-
? `pnpm wait-port ${port} && pnpm dev --port ${port}`
65-
: `pnpm wait-port ${port} && pnpm preview --port ${port}`,
66+
? `pnpm wait-port ${eventProxyPort} && pnpm dev --port ${port}`
67+
: `pnpm wait-port ${eventProxyPort} && pnpm preview --port ${port}`,
6668
port,
6769
},
6870
],

dev-packages/e2e-tests/test-applications/sveltekit/src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width" />
77
%sveltekit.head%
88
</head>
9-
<body data-sveltekit-preload-data="hover">
9+
<body data-sveltekit-preload-data="off">
1010
<div style="display: contents">%sveltekit.body%</div>
1111
</body>
1212
</html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script lang="typescript">
2+
import { onMount } from 'svelte';
3+
4+
onMount(() => {
5+
// Indicate that the SvelteKit app was hydrated
6+
document.body.classList.add('hydrated');
7+
});
8+
</script>
9+
10+
<slot />
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
11
<h1>Welcome to SvelteKit</h1>
22
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
3+
4+
<ul>
5+
<li>
6+
<a href="/client-error">Client error</a>
7+
</li>
8+
<li>
9+
<a href="/universal-load-error">Universal Load error</a>
10+
</li>
11+
<li>
12+
<a href="/server-load-error">Server Load error</a>
13+
</li>
14+
<li>
15+
<a href="/server-route-error">Server Route error</a>
16+
</li>
17+
<li>
18+
<a href="/users/123abc">Route with Params</a>
19+
</li>
20+
<li>
21+
<a href="/users">Route with Server Load</a>
22+
</li>
23+
<li>
24+
<a href="/universal-load-fetch">Route with fetch in universal load</a>
25+
</li>
26+
</ul>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const GET = () => {
2+
return new Response(JSON.stringify({ users: ['alice', 'bob', 'carol'] }));
3+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script lang="ts">
2+
function throwError() {
3+
throw new Error('Click Error');
4+
}
5+
</script>
6+
7+
<h1>Client error</h1>
8+
9+
<button on:click={throwError}>Throw error</button>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const load = async () => {
2+
throw new Error('Server Load Error');
3+
return {
4+
msg: 'Hello World',
5+
};
6+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script lang="ts">
2+
export let data
3+
</script>
4+
5+
<h1>Server load error</h1>
6+
7+
<p>
8+
Message: {data.msg}
9+
</p>

0 commit comments

Comments
 (0)