|
1 | | -import { RewriteFrames } from '@sentry/integrations'; |
2 | | -import type { Event, StackFrame } from '@sentry/types'; |
3 | | -import { basename } from '@sentry/utils'; |
4 | | - |
5 | | -import type { GlobalWithSentryValues } from '../../src/server/utils'; |
6 | | -import { getTracePropagationData, rewriteFramesIteratee } from '../../src/server/utils'; |
| 1 | +import { getTracePropagationData } from '../../src/server/utils'; |
7 | 2 |
|
8 | 3 | const MOCK_REQUEST_EVENT: any = { |
9 | 4 | request: { |
@@ -58,85 +53,3 @@ describe('getTracePropagationData', () => { |
58 | 53 | expect(dynamicSamplingContext).toBeUndefined(); |
59 | 54 | }); |
60 | 55 | }); |
61 | | - |
62 | | -describe('rewriteFramesIteratee', () => { |
63 | | - it('removes the module property from the frame', () => { |
64 | | - const frame: StackFrame = { |
65 | | - filename: '/some/path/to/server/chunks/3-ab34d22f.js', |
66 | | - module: '3-ab34d22f.js', |
67 | | - }; |
68 | | - |
69 | | - const result = rewriteFramesIteratee(frame); |
70 | | - |
71 | | - expect(result).not.toHaveProperty('module'); |
72 | | - }); |
73 | | - |
74 | | - it('does the same filename modification as the default RewriteFrames iteratee if no output dir is available', () => { |
75 | | - const frame: StackFrame = { |
76 | | - filename: '/some/path/to/server/chunks/3-ab34d22f.js', |
77 | | - lineno: 1, |
78 | | - colno: 1, |
79 | | - module: '3-ab34d22f.js', |
80 | | - }; |
81 | | - |
82 | | - // eslint-disable-next-line deprecation/deprecation |
83 | | - const originalRewriteFrames = new RewriteFrames(); |
84 | | - // eslint-disable-next-line deprecation/deprecation |
85 | | - const rewriteFrames = new RewriteFrames({ iteratee: rewriteFramesIteratee }); |
86 | | - |
87 | | - const event: Event = { |
88 | | - exception: { |
89 | | - values: [ |
90 | | - { |
91 | | - stacktrace: { |
92 | | - frames: [frame], |
93 | | - }, |
94 | | - }, |
95 | | - ], |
96 | | - }, |
97 | | - }; |
98 | | - |
99 | | - const originalResult = originalRewriteFrames.processEvent(event); |
100 | | - const result = rewriteFrames.processEvent(event); |
101 | | - |
102 | | - expect(result.exception?.values?.[0]?.stacktrace?.frames?.[0]).toEqual({ |
103 | | - filename: 'app:///3-ab34d22f.js', |
104 | | - lineno: 1, |
105 | | - colno: 1, |
106 | | - }); |
107 | | - |
108 | | - expect(result).toStrictEqual(originalResult); |
109 | | - }); |
110 | | - |
111 | | - it.each([ |
112 | | - ['adapter-node', 'build', '/absolute/path/to/build/server/chunks/3-ab34d22f.js', 'app:///chunks/3-ab34d22f.js'], |
113 | | - [ |
114 | | - 'adapter-auto', |
115 | | - '.svelte-kit/output', |
116 | | - '/absolute/path/to/.svelte-kit/output/server/entries/pages/page.ts.js', |
117 | | - 'app:///entries/pages/page.ts.js', |
118 | | - ], |
119 | | - ])( |
120 | | - 'removes the absolut path to the server output dir, if the output dir is available (%s)', |
121 | | - (_, outputDir, frameFilename, modifiedFilename) => { |
122 | | - (globalThis as GlobalWithSentryValues).__sentry_sveltekit_output_dir = outputDir; |
123 | | - |
124 | | - const frame: StackFrame = { |
125 | | - filename: frameFilename, |
126 | | - lineno: 1, |
127 | | - colno: 1, |
128 | | - module: basename(frameFilename), |
129 | | - }; |
130 | | - |
131 | | - const result = rewriteFramesIteratee({ ...frame }); |
132 | | - |
133 | | - expect(result).toStrictEqual({ |
134 | | - filename: modifiedFilename, |
135 | | - lineno: 1, |
136 | | - colno: 1, |
137 | | - }); |
138 | | - |
139 | | - delete (globalThis as GlobalWithSentryValues).__sentry_sveltekit_output_dir; |
140 | | - }, |
141 | | - ); |
142 | | -}); |
0 commit comments