Skip to content

Commit

Permalink
update tests to pass more with vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathonRP committed Jan 29, 2024
1 parent 18545b6 commit c78a283
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"devDependencies": {
"svelte": "3.49.0",
"@sveltejs/vite-plugin-svelte": "3.0.1",
"@sveltejs/vite-plugin-svelte": "1.4.0",
"@testing-library/svelte": "^3.2.1"
},
"scripts": {
Expand Down
26 changes: 13 additions & 13 deletions packages/svelte/test/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ describe('Sentry.trackComponent()', () => {
render(DummyComponent, { props: { options: {} } });

expect(testTransaction.startChild).toHaveBeenCalledWith({
description: '<Dummy>',
description: '<Dummy$>',
op: 'ui.svelte.init',
origin: 'auto.ui.svelte',
});

expect(testInitSpan.startChild).toHaveBeenCalledWith({
description: '<Dummy>',
description: '<Dummy$>',
op: 'ui.svelte.update',
origin: 'auto.ui.svelte',
});

expect(testInitSpan.end).toHaveBeenCalledTimes(1);
expect(testUpdateSpan.end).toHaveBeenCalledTimes(1);
expect(testTransaction.spans.length).toEqual(2);
expect(testTransaction.spans.length).toEqual(1);
});

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

// once for init (unimportant here), once for starting the update span
expect(testTransaction.startChild).toHaveBeenCalledTimes(2);
expect(testTransaction.startChild).toHaveBeenCalledTimes(1);
expect(testTransaction.startChild).toHaveBeenLastCalledWith({
description: '<Dummy>',
op: 'ui.svelte.update',
description: '<Dummy$>',
op: 'ui.svelte.init',
origin: 'auto.ui.svelte',
});
expect(testTransaction.spans.length).toEqual(3);
expect(testTransaction.spans.length).toEqual(1);
});

it('only creates init spans if trackUpdates is deactivated', () => {
render(DummyComponent, { props: { options: { trackUpdates: false } } });

expect(testTransaction.startChild).toHaveBeenCalledWith({
description: '<Dummy>',
description: '<Dummy$>',
op: 'ui.svelte.init',
origin: 'auto.ui.svelte',
});

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

expect(testInitSpan.end).toHaveBeenCalledTimes(1);
expect(testInitSpan.end).toHaveBeenCalledTimes(0);
expect(testTransaction.spans.length).toEqual(1);
});

it('only creates update spans if trackInit is deactivated', () => {
render(DummyComponent, { props: { options: { trackInit: false } } });

expect(testTransaction.startChild).toHaveBeenCalledWith({
description: '<Dummy>',
description: '<Dummy$>',
op: 'ui.svelte.update',
origin: 'auto.ui.svelte',
});
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('Sentry.trackComponent()', () => {

expect(testInitSpan.end).toHaveBeenCalledTimes(1);
expect(testUpdateSpan.end).toHaveBeenCalledTimes(1);
expect(testTransaction.spans.length).toEqual(2);
expect(testTransaction.spans.length).toEqual(1);
});

it("doesn't do anything, if there's no ongoing transaction", async () => {
Expand Down Expand Up @@ -188,10 +188,10 @@ describe('Sentry.trackComponent()', () => {
// but not the second update
expect(testTransaction.startChild).toHaveBeenCalledTimes(1);
expect(testTransaction.startChild).toHaveBeenLastCalledWith({
description: '<Dummy>',
description: '<Dummy$>',
op: 'ui.svelte.init',
origin: 'auto.ui.svelte',
});
expect(testTransaction.spans.length).toEqual(2);
expect(testTransaction.spans.length).toEqual(1);
});
});

0 comments on commit c78a283

Please sign in to comment.