Skip to content

Commit 63a2175

Browse files
committed
test: update test expectations
1 parent 31c5cbd commit 63a2175

File tree

1 file changed

+23
-45
lines changed

1 file changed

+23
-45
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', () => {

0 commit comments

Comments
 (0)