Skip to content

Commit 88b39bf

Browse files
committed
[minor] fix: svelte 4/5 lifecycle events not firing
1 parent 1e2030e commit 88b39bf

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/svelte/test/performance.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('Sentry.trackComponent()', () => {
7272

7373
expect(testInitSpan.end).toHaveBeenCalledTimes(1);
7474
expect(testUpdateSpan.end).toHaveBeenCalledTimes(1);
75-
expect(testTransaction.spans.length).toEqual(1);
75+
expect(testTransaction.spans.length).toEqual(2);
7676
});
7777

7878
it('creates an update span, when the component is updated', async () => {
@@ -90,13 +90,13 @@ describe('Sentry.trackComponent()', () => {
9090
await act(() => component.$set({ options: { trackUpdates: true } }));
9191

9292
// once for init (unimportant here), once for starting the update span
93-
expect(testTransaction.startChild).toHaveBeenCalledTimes(1);
93+
expect(testTransaction.startChild).toHaveBeenCalledTimes(2);
9494
expect(testTransaction.startChild).toHaveBeenLastCalledWith({
9595
description: '<Dummy$>',
96-
op: 'ui.svelte.init',
96+
op: 'ui.svelte.update',
9797
origin: 'auto.ui.svelte',
9898
});
99-
expect(testTransaction.spans.length).toEqual(1);
99+
expect(testTransaction.spans.length).toEqual(3);
100100
});
101101

102102
it('only creates init spans if trackUpdates is deactivated', () => {
@@ -110,7 +110,7 @@ describe('Sentry.trackComponent()', () => {
110110

111111
expect(testInitSpan.startChild).not.toHaveBeenCalled();
112112

113-
expect(testInitSpan.end).toHaveBeenCalledTimes(0);
113+
expect(testInitSpan.end).toHaveBeenCalledTimes(1);
114114
expect(testTransaction.spans.length).toEqual(1);
115115
});
116116

@@ -156,7 +156,7 @@ describe('Sentry.trackComponent()', () => {
156156

157157
expect(testInitSpan.end).toHaveBeenCalledTimes(1);
158158
expect(testUpdateSpan.end).toHaveBeenCalledTimes(1);
159-
expect(testTransaction.spans.length).toEqual(1);
159+
expect(testTransaction.spans.length).toEqual(2);
160160
});
161161

162162
it("doesn't do anything, if there's no ongoing transaction", async () => {
@@ -192,6 +192,6 @@ describe('Sentry.trackComponent()', () => {
192192
op: 'ui.svelte.init',
193193
origin: 'auto.ui.svelte',
194194
});
195-
expect(testTransaction.spans.length).toEqual(1);
195+
expect(testTransaction.spans.length).toEqual(2);
196196
});
197197
});

packages/svelte/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export default {
1010
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1111
...(baseConfig as UserConfig & { test: any }).test,
1212
environment: 'jsdom',
13+
alias: [{ find: /^svelte$/, replacement: 'svelte/internal' }],
1314
},
1415
};

0 commit comments

Comments
 (0)