Skip to content

Commit 1583866

Browse files
committed
test: update test expectations
1 parent d57e477 commit 1583866

File tree

2 files changed

+52
-107
lines changed

2 files changed

+52
-107
lines changed

packages/nitro/test/sourceMaps.test.ts

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { debug } from '@sentry/core';
12
import type { NitroConfig } from 'nitro/types';
23
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
34
import type { SentryNitroOptions } from '../src/config';
45
import { setupSentryNitroModule } from '../src/config';
5-
import { getPluginOptions, setupSourceMaps } from '../src/sourceMaps';
6+
import { configureSourcemapSettings, getPluginOptions, setupSourceMaps } from '../src/sourceMaps';
67

78
vi.mock('../src/instruments/instrumentServer', () => ({
89
instrumentServer: vi.fn(),
@@ -131,96 +132,65 @@ describe('getPluginOptions', () => {
131132
});
132133
});
133134

134-
describe('setupSentryNitroModule', () => {
135+
describe('configureSourcemapSettings', () => {
135136
it('enables sourcemap generation on the config', () => {
136137
const config: NitroConfig = {};
137-
setupSentryNitroModule(config);
138+
configureSourcemapSettings(config);
138139

139140
expect(config.sourcemap).toBe(true);
140141
});
141142

142143
it('forces sourcemap to true even when user set it to false', () => {
143-
const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
144+
const debugSpy = vi.spyOn(debug, 'warn').mockImplementation(() => {});
144145
const config: NitroConfig = { sourcemap: false };
145-
setupSentryNitroModule(config);
146+
configureSourcemapSettings(config);
146147

147148
expect(config.sourcemap).toBe(true);
148-
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('overriding this to `true`'));
149-
consoleSpy.mockRestore();
149+
expect(debugSpy).toHaveBeenCalledWith(expect.stringContaining('overriding this to `true`'));
150+
debugSpy.mockRestore();
150151
});
151152

152153
it('keeps sourcemap true when user already set it', () => {
153154
const config: NitroConfig = { sourcemap: true };
154-
setupSentryNitroModule(config);
155+
configureSourcemapSettings(config);
155156

156157
expect(config.sourcemap).toBe(true);
157158
});
158159

159160
it('disables experimental sourcemapMinify', () => {
160161
const config: NitroConfig = {};
161-
setupSentryNitroModule(config);
162+
configureSourcemapSettings(config);
162163

163164
expect(config.experimental?.sourcemapMinify).toBe(false);
164165
});
165166

166-
it('sets sourcemapExcludeSources to false in rollupConfig', () => {
167-
const config: NitroConfig = {};
168-
setupSentryNitroModule(config);
169-
170-
expect(config.rollupConfig?.output?.sourcemapExcludeSources).toBe(false);
171-
});
172-
173167
it('preserves existing experimental config', () => {
174168
const config: NitroConfig = {
175169
experimental: {
176170
sourcemapMinify: undefined,
177171
},
178172
};
179-
setupSentryNitroModule(config);
173+
configureSourcemapSettings(config);
180174

181175
expect(config.experimental?.sourcemapMinify).toBe(false);
182176
});
183177

184-
it('preserves existing rollupConfig', () => {
185-
const config: NitroConfig = {
186-
rollupConfig: {
187-
output: {
188-
format: 'esm' as const,
189-
},
190-
},
191-
};
192-
setupSentryNitroModule(config);
193-
194-
expect(config.rollupConfig?.output?.format).toBe('esm');
195-
expect(config.rollupConfig?.output?.sourcemapExcludeSources).toBe(false);
196-
});
197-
198178
it('skips sourcemap config when sourcemaps.disable is true', () => {
199179
const config: NitroConfig = { sourcemap: false };
200-
setupSentryNitroModule(config, { sourcemaps: { disable: true } });
180+
configureSourcemapSettings(config, { sourcemaps: { disable: true } });
201181

202-
// Should NOT override the user's sourcemap: false
203182
expect(config.sourcemap).toBe(false);
204-
expect(config.rollupConfig).toBeUndefined();
205183
});
206184

207185
it('skips sourcemap config when disable is true', () => {
208186
const config: NitroConfig = { sourcemap: false };
209-
setupSentryNitroModule(config, { disable: true });
187+
configureSourcemapSettings(config, { disable: true });
210188

211-
// Should NOT override the user's sourcemap: false
212189
expect(config.sourcemap).toBe(false);
213-
expect(config.rollupConfig).toBeUndefined();
214-
});
215-
216-
it('still adds module when sourcemaps are disabled', () => {
217-
const config: NitroConfig = {};
218-
setupSentryNitroModule(config, { sourcemaps: { disable: true } });
219-
220-
expect(config.modules).toBeDefined();
221-
expect(config.modules?.length).toBe(1);
222190
});
191+
});
223192

193+
describe('setupSentryNitroModule', () => {
224194
it('enables tracing', () => {
225195
const config: NitroConfig = {};
226196
setupSentryNitroModule(config);
@@ -236,6 +206,14 @@ describe('setupSentryNitroModule', () => {
236206
expect(config.modules).toBeDefined();
237207
expect(config.modules?.length).toBe(1);
238208
});
209+
210+
it('still adds module when sourcemaps are disabled', () => {
211+
const config: NitroConfig = {};
212+
setupSentryNitroModule(config, { sourcemaps: { disable: true } });
213+
214+
expect(config.modules).toBeDefined();
215+
expect(config.modules?.length).toBe(1);
216+
});
239217
});
240218

241219
describe('setupSourceMaps', () => {

yarn.lock

Lines changed: 29 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5005,18 +5005,6 @@
50055005
resolved "https://registry.yarnpkg.com/@ioredis/commands/-/commands-1.5.0.tgz#3dddcea446a4b1dc177d0743a1e07ff50691652a"
50065006
integrity sha512-eUgLqrMf8nJkZxT24JvVRrQya1vZkQh8BBeYNwGDqa5I0VUi8ACx7uFvAaLxintokpTenkK6DASvo/bvNbBGow==
50075007

5008-
"@isaacs/balanced-match@^4.0.1":
5009-
version "4.0.1"
5010-
resolved "https://registry.yarnpkg.com/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz#3081dadbc3460661b751e7591d7faea5df39dd29"
5011-
integrity sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==
5012-
5013-
"@isaacs/brace-expansion@^5.0.0":
5014-
version "5.0.1"
5015-
resolved "https://registry.yarnpkg.com/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz#0ef5a92d91f2fff2a37646ce54da9e5f599f6eff"
5016-
integrity sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==
5017-
dependencies:
5018-
"@isaacs/balanced-match" "^4.0.1"
5019-
50205008
"@isaacs/cliui@^8.0.2":
50215009
version "8.0.2"
50225010
resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550"
@@ -21984,35 +21972,21 @@ minimalistic-assert@^1.0.0:
2198421972
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
2198521973
integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==
2198621974

21987-
minimatch@10.1.1:
21988-
version "10.1.1"
21989-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.1.1.tgz#e6e61b9b0c1dcab116b5a7d1458e8b6ae9e73a55"
21990-
integrity sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==
21975+
minimatch@10.1.1, minimatch@10.2.4, minimatch@^10.2.2, minimatch@^10.2.4:
21976+
version "10.2.4"
21977+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.2.4.tgz#465b3accbd0218b8281f5301e27cedc697f96fde"
21978+
integrity sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==
2199121979
dependencies:
21992-
"@isaacs/brace-expansion" "^5.0.0"
21980+
brace-expansion "^5.0.2"
2199321981

21994-
"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
21982+
"minimatch@2 || 3", minimatch@3.1.5, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2, minimatch@~3.0.4:
2199521983
version "3.1.5"
2199621984
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.5.tgz#580c88f8d5445f2bd6aa8f3cadefa0de79fbd69e"
2199721985
integrity sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==
2199821986
dependencies:
2199921987
brace-expansion "^1.1.7"
2200021988

22001-
minimatch@5.1.0:
22002-
version "5.1.0"
22003-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz#1717b464f4971b144f6aabe8f2d0b8e4511e09c7"
22004-
integrity sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==
22005-
dependencies:
22006-
brace-expansion "^2.0.1"
22007-
22008-
minimatch@^10.2.2, minimatch@^10.2.4:
22009-
version "10.2.4"
22010-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.2.4.tgz#465b3accbd0218b8281f5301e27cedc697f96fde"
22011-
integrity sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==
22012-
dependencies:
22013-
brace-expansion "^5.0.2"
22014-
22015-
minimatch@^5.0.1, minimatch@^5.1.0:
21989+
minimatch@5.1.0, minimatch@5.1.9, minimatch@^5.0.1, minimatch@^5.1.0:
2201621990
version "5.1.9"
2201721991
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.9.tgz#1293ef15db0098b394540e8f9f744f9fda8dee4b"
2201821992
integrity sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==
@@ -22040,13 +22014,6 @@ minimatch@^9.0.0, minimatch@^9.0.4:
2204022014
dependencies:
2204122015
brace-expansion "^5.0.2"
2204222016

22043-
minimatch@~3.0.4:
22044-
version "3.0.8"
22045-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.8.tgz#5e6a59bd11e2ab0de1cfb843eb2d82e546c321c1"
22046-
integrity sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==
22047-
dependencies:
22048-
brace-expansion "^1.1.7"
22049-
2205022017
minimist@^0.2.1:
2205122018
version "0.2.4"
2205222019
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.2.4.tgz#0085d5501e29033748a2f2a4da0180142697a475"
@@ -24177,6 +24144,11 @@ path-scurry@^2.0.2:
2417724144
lru-cache "^11.0.0"
2417824145
minipass "^7.1.2"
2417924146

24147+
path-to-regexp@0.1.12, path-to-regexp@~0.1.12:
24148+
version "0.1.12"
24149+
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.12.tgz#d5e1a12e478a976d432ef3c58d534b9923164bb7"
24150+
integrity sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==
24151+
2418024152
path-to-regexp@3.3.0:
2418124153
version "3.3.0"
2418224154
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-3.3.0.tgz#f7f31d32e8518c2660862b644414b6d5c63a611b"
@@ -24204,11 +24176,6 @@ path-to-regexp@^1.5.3, path-to-regexp@^1.7.0:
2420424176
dependencies:
2420524177
isarray "0.0.1"
2420624178

24207-
path-to-regexp@~0.1.12:
24208-
version "0.1.12"
24209-
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.12.tgz#d5e1a12e478a976d432ef3c58d534b9923164bb7"
24210-
integrity sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==
24211-
2421224179
path-type@^4.0.0:
2421324180
version "4.0.0"
2421424181
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
@@ -28054,7 +28021,7 @@ string-template@~0.2.1:
2805428021
is-fullwidth-code-point "^3.0.0"
2805528022
strip-ansi "^6.0.1"
2805628023

28057-
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
28024+
string-width@4.2.3, "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
2805828025
version "4.2.3"
2805928026
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
2806028027
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -28187,6 +28154,13 @@ stringify-object@^3.2.1:
2818728154
dependencies:
2818828155
ansi-regex "^5.0.1"
2818928156

28157+
strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1:
28158+
version "6.0.1"
28159+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
28160+
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
28161+
dependencies:
28162+
ansi-regex "^5.0.1"
28163+
2819028164
strip-ansi@^3.0.0:
2819128165
version "3.0.1"
2819228166
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
@@ -28208,13 +28182,6 @@ strip-ansi@^5.1.0, strip-ansi@^5.2.0:
2820828182
dependencies:
2820928183
ansi-regex "^4.1.0"
2821028184

28211-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
28212-
version "6.0.1"
28213-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
28214-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
28215-
dependencies:
28216-
ansi-regex "^5.0.1"
28217-
2821828185
strip-ansi@^7.0.1, strip-ansi@^7.1.0:
2821928186
version "7.1.0"
2822028187
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -28353,7 +28320,7 @@ stylus@0.59.0, stylus@^0.59.0:
2835328320
sax "~1.2.4"
2835428321
source-map "^0.7.3"
2835528322

28356-
sucrase@^3.27.0, sucrase@^3.35.0:
28323+
sucrase@^3.27.0, sucrase@^3.35.0, sucrase@getsentry/sucrase#es2020-polyfills:
2835728324
version "3.36.0"
2835828325
resolved "https://codeload.github.com/getsentry/sucrase/tar.gz/fd682f6129e507c00bb4e6319cc5d6b767e36061"
2835928326
dependencies:
@@ -30982,19 +30949,19 @@ wrangler@4.62.0:
3098230949
string-width "^4.1.0"
3098330950
strip-ansi "^6.0.0"
3098430951

30985-
wrap-ansi@^6.0.1:
30986-
version "6.2.0"
30987-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
30988-
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
30952+
wrap-ansi@7.0.0, wrap-ansi@^7.0.0:
30953+
version "7.0.0"
30954+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
30955+
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
3098930956
dependencies:
3099030957
ansi-styles "^4.0.0"
3099130958
string-width "^4.1.0"
3099230959
strip-ansi "^6.0.0"
3099330960

30994-
wrap-ansi@^7.0.0:
30995-
version "7.0.0"
30996-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
30997-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
30961+
wrap-ansi@^6.0.1:
30962+
version "6.2.0"
30963+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
30964+
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
3099830965
dependencies:
3099930966
ansi-styles "^4.0.0"
3100030967
string-width "^4.1.0"

0 commit comments

Comments
 (0)