-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsentryTanstackStart.test.ts
More file actions
82 lines (63 loc) · 2.61 KB
/
sentryTanstackStart.test.ts
File metadata and controls
82 lines (63 loc) · 2.61 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
import type { Plugin } from 'vite';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { sentryTanstackStart } from '../../src/vite/sentryTanstackStart';
const mockSourceMapsConfigPlugin: Plugin = {
name: 'sentry-tanstackstart-files-to-delete-after-upload-plugin',
apply: 'build',
enforce: 'pre',
config: vi.fn(),
};
const mockSentryVitePlugin: Plugin = {
name: 'sentry-vite-debug-id-upload-plugin',
writeBundle: vi.fn(),
};
const mockEnableSourceMapsPlugin: Plugin = {
name: 'sentry-tanstackstart-react-source-maps',
apply: 'build',
enforce: 'post',
config: vi.fn(),
};
vi.mock('../../src/vite/sourceMaps', () => ({
makeAddSentryVitePlugin: vi.fn(() => [mockSourceMapsConfigPlugin, mockSentryVitePlugin]),
makeEnableSourceMapsVitePlugin: vi.fn(() => [mockEnableSourceMapsPlugin]),
}));
describe('sentryTanstackStart()', () => {
beforeEach(() => {
vi.clearAllMocks();
process.env.NODE_ENV = 'production';
});
afterEach(() => {
process.env.NODE_ENV = 'production';
});
it('returns plugins in production mode', () => {
const plugins = sentryTanstackStart({ org: 'test-org' });
expect(plugins).toEqual([mockSourceMapsConfigPlugin, mockSentryVitePlugin, mockEnableSourceMapsPlugin]);
});
it('returns no plugins in development mode', () => {
process.env.NODE_ENV = 'development';
const plugins = sentryTanstackStart({ org: 'test-org' });
expect(plugins).toEqual([]);
});
it('returns Sentry Vite plugins but not enable source maps plugin when sourcemaps.disable is true', () => {
const plugins = sentryTanstackStart({
sourcemaps: { disable: true },
});
expect(plugins).toEqual([mockSourceMapsConfigPlugin, mockSentryVitePlugin]);
});
it('returns Sentry Vite plugins but not enable source maps plugin when sourcemaps.disable is "disable-upload"', () => {
const plugins = sentryTanstackStart({
sourcemaps: { disable: 'disable-upload' },
});
expect(plugins).toEqual([mockSourceMapsConfigPlugin, mockSentryVitePlugin]);
});
it('returns Sentry Vite plugins and enable source maps plugin when sourcemaps.disable is false', () => {
const plugins = sentryTanstackStart({
sourcemaps: { disable: false },
});
expect(plugins).toEqual([mockSourceMapsConfigPlugin, mockSentryVitePlugin, mockEnableSourceMapsPlugin]);
});
it('returns Sentry Vite Plugins and enable source maps plugin by default when sourcemaps is not specified', () => {
const plugins = sentryTanstackStart({});
expect(plugins).toEqual([mockSourceMapsConfigPlugin, mockSentryVitePlugin, mockEnableSourceMapsPlugin]);
});
});