Skip to content

Commit fee75e5

Browse files
committed
test: 🧪 add svelte-kit end to end test
1 parent 982b127 commit fee75e5

File tree

10 files changed

+111
-0
lines changed

10 files changed

+111
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "svelte-app",
3+
"private": true,
4+
"version": "0.0.1",
5+
"type": "module",
6+
"scripts": {
7+
"build": "vite build"
8+
},
9+
"devDependencies": {
10+
"@sveltejs/adapter-auto": "^4.0.0",
11+
"@sveltejs/kit": "^2.16.0",
12+
"@sveltejs/vite-plugin-svelte": "^5.0.0",
13+
"svelte": "^5.0.0",
14+
"vite": "^6.0.0"
15+
}
16+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script>
2+
let { children } = $props();
3+
4+
import { afterNavigate, beforeNavigate } from '$app/navigation';
5+
import BugsnagPerformance from '@bugsnag/browser-performance';
6+
import { SvelteKitRoutingProvider } from '@bugsnag/svelte-kit-performance';
7+
8+
BugsnagPerformance.start({
9+
apiKey: 'd87bab7258fc1b8c236c1d21a6665634',
10+
routingProvider: new SvelteKitRoutingProvider(beforeNavigate, afterNavigate)
11+
})
12+
</script>
13+
14+
<nav>
15+
<a href="/">Home</a>
16+
<a href="/contact/1" id="contact">Contact 1</a>
17+
<a href="/contact/2" id="contact-2">Contact 2</a>
18+
<a href="/contact/3" id="contact-3">Contact 3</a>
19+
</nav>
20+
21+
{@render children()}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>SvelteKit Test</h1>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Contact</h1>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<head>
2+
<title>Contact</title>
3+
</head>
4+
5+
<h1>Contact</h1>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Profile</h1>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import adapter from '@sveltejs/adapter-auto';
2+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
3+
4+
/** @type {import('@sveltejs/kit').Config} */
5+
const config = {
6+
// Consult https://svelte.dev/docs/kit/integrations
7+
// for more information about preprocessors
8+
preprocess: vitePreprocess(),
9+
10+
kit: {
11+
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
12+
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
13+
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
14+
adapter: adapter()
15+
}
16+
};
17+
18+
export default config;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "./.svelte-kit/tsconfig.json",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"checkJs": true,
6+
"esModuleInterop": true,
7+
"forceConsistentCasingInFileNames": true,
8+
"resolveJsonModule": true,
9+
"skipLibCheck": true,
10+
"sourceMap": true,
11+
"strict": true,
12+
// "moduleResolution": "bundler"
13+
}
14+
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
15+
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
16+
//
17+
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
18+
// from the referenced tsconfig.json - TypeScript does not merge them in
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { sveltekit } from '@sveltejs/kit/vite';
2+
import { defineConfig } from 'vite';
3+
4+
export default defineConfig({
5+
plugins: [sveltekit()]
6+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Feature: SvelteKit router
2+
3+
Scenario: SvelteKit route change spans are automatically instrumented
4+
Given I navigate to the test URL "/docs/svelte-kit"
5+
And I click the element "contact"
6+
And I click the element "profile"
7+
When I wait to receive 2 spans
8+
9+
Then a span named "[RouteChange]/contacts/[contactId]" contains the attributes:
10+
| attribute | type | value |
11+
| bugsnag.span.category | stringValue | route_change |
12+
| bugsnag.browser.page.title | stringValue | Contact 1 |
13+
| bugsnag.browser.page.route | stringValue | /contacts/[contactId] |
14+
| bugsnag.browser.page.previous_route | stringValue | / |
15+
| bugsnag.browser.page.route_change.trigger | stringValue | link |
16+
17+
And a span named "[RouteChange]/contacts/[contactId]/profile" contains the attributes:
18+
| attribute | type | value |
19+
| bugsnag.span.category | stringValue | route_change |
20+
| bugsnag.browser.page.title | stringValue | Contact Profile |
21+
| bugsnag.browser.page.route | stringValue | /contacts/[contactId]/profile |
22+
| bugsnag.browser.page.previous_route | stringValue | /contacts/[contactId] |
23+
| bugsnag.browser.page.route_change.trigger | stringValue | link |

0 commit comments

Comments
 (0)