Skip to content

Commit 95679d7

Browse files
committed
test
1 parent 6e30ae3 commit 95679d7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

packages/sveltekit/test/client/load.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,43 @@ describe('wrapLoadWithSentry', () => {
9999
expect(mockCaptureException).toHaveBeenCalledTimes(1);
100100
});
101101

102+
it('calls trace function', async () => {
103+
async function load({ params }: Parameters<Load>[0]): Promise<ReturnType<Load>> {
104+
return {
105+
post: params.id,
106+
};
107+
}
108+
109+
const wrappedLoad = wrapLoadWithSentry(load);
110+
await wrappedLoad(MOCK_LOAD_ARGS);
111+
112+
expect(mockTrace).toHaveBeenCalledTimes(1);
113+
expect(mockTrace).toHaveBeenCalledWith(
114+
{
115+
op: 'function.sveltekit.load',
116+
name: '/users/[id]',
117+
parentSampled: true,
118+
parentSpanId: '1234567890abcdef',
119+
status: 'ok',
120+
traceId: '1234567890abcdef1234567890abcdef',
121+
metadata: {
122+
dynamicSamplingContext: {
123+
environment: 'production',
124+
public_key: 'dogsarebadatkeepingsecrets',
125+
release: '1.0.0',
126+
sample_rate: '1',
127+
trace_id: '1234567890abcdef1234567890abcdef',
128+
transaction: 'dogpark',
129+
user_segment: 'segmentA',
130+
},
131+
source: 'route',
132+
},
133+
},
134+
expect.any(Function),
135+
expect.any(Function),
136+
);
137+
});
138+
102139
it('adds an exception mechanism', async () => {
103140
const addEventProcessorSpy = vi.spyOn(mockScope, 'addEventProcessor').mockImplementationOnce(callback => {
104141
void callback({}, { event_id: 'fake-event-id' });

0 commit comments

Comments
 (0)