-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathrewriteFramesIntegration.test.ts
More file actions
87 lines (73 loc) · 2.73 KB
/
rewriteFramesIntegration.test.ts
File metadata and controls
87 lines (73 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { rewriteFramesIntegration } from '@sentry/browser';
import type { Event, StackFrame } from '@sentry/core';
import { basename } from '@sentry/core';
import { describe, expect, it } from 'vitest';
import { rewriteFramesIteratee } from '../../src/server-common/rewriteFramesIntegration';
import type { GlobalWithSentryValues } from '../../src/vite/injectGlobalValues';
describe('rewriteFramesIteratee', () => {
it('removes the module property from the frame', () => {
const frame: StackFrame = {
filename: '/some/path/to/server/chunks/3-ab34d22f.js',
module: '3-ab34d22f.js',
};
const result = rewriteFramesIteratee(frame);
expect(result).not.toHaveProperty('module');
});
it('does the same filename modification as the default RewriteFrames iteratee if no output dir is available', () => {
const frame: StackFrame = {
filename: '/some/path/to/server/chunks/3-ab34d22f.js',
lineno: 1,
colno: 1,
module: '3-ab34d22f.js',
};
const originalRewriteFrames = rewriteFramesIntegration();
const rewriteFrames = rewriteFramesIntegration({ iteratee: rewriteFramesIteratee });
const event: Event = {
exception: {
values: [
{
stacktrace: {
frames: [frame],
},
},
],
},
};
const originalResult = originalRewriteFrames.processEvent?.(event, {}, {} as any);
const result = rewriteFrames.processEvent?.(event, {}, {} as any) as Event;
expect(result.exception?.values?.[0]?.stacktrace?.frames?.[0]).toEqual({
filename: 'app:///3-ab34d22f.js',
abs_path: '/some/path/to/server/chunks/3-ab34d22f.js',
lineno: 1,
colno: 1,
});
expect(result).toStrictEqual(originalResult);
});
it.each([
['adapter-node', 'build', '/absolute/path/to/build/server/chunks/3-ab34d22f.js', 'app:///chunks/3-ab34d22f.js'],
[
'adapter-auto',
'.svelte-kit/output',
'/absolute/path/to/.svelte-kit/output/server/entries/pages/page.ts.js',
'app:///entries/pages/page.ts.js',
],
])(
'removes the absolut path to the server output dir, if the output dir is available (%s)',
(_, outputDir, frameFilename, modifiedFilename) => {
(globalThis as unknown as GlobalWithSentryValues).__sentry_sveltekit_output_dir = outputDir;
const frame: StackFrame = {
filename: frameFilename,
lineno: 1,
colno: 1,
module: basename(frameFilename),
};
const result = rewriteFramesIteratee({ ...frame });
expect(result).toStrictEqual({
filename: modifiedFilename,
lineno: 1,
colno: 1,
});
delete (globalThis as unknown as GlobalWithSentryValues).__sentry_sveltekit_output_dir;
},
);
});