-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathmakeCustomSentryVitePlugins.test.ts
More file actions
87 lines (75 loc) · 2.26 KB
/
makeCustomSentryVitePlugins.test.ts
File metadata and controls
87 lines (75 loc) · 2.26 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 { sentryVitePlugin } from '@sentry/vite-plugin';
import { describe, expect, it, vi } from 'vitest';
import { makeCustomSentryVitePlugins } from '../../src/vite/makeCustomSentryVitePlugins';
vi.mock('@sentry/vite-plugin', () => ({
sentryVitePlugin: vi.fn().mockReturnValue([{ name: 'sentry-vite-plugin' }]),
}));
describe('makeCustomSentryVitePlugins', () => {
it('should pass release configuration to sentryVitePlugin', async () => {
const options = {
release: {
name: 'test-release',
},
};
await makeCustomSentryVitePlugins(options);
expect(sentryVitePlugin).toHaveBeenCalledWith(
expect.objectContaining({
release: {
name: 'test-release',
},
}),
);
});
it('should merge release configuration with unstable_sentryVitePluginOptions', async () => {
const options = {
release: {
name: 'test-release',
},
unstable_sentryVitePluginOptions: {
release: {
name: 'unstable-release',
},
},
};
await makeCustomSentryVitePlugins(options);
expect(sentryVitePlugin).toHaveBeenCalledWith(
expect.objectContaining({
release: {
name: 'test-release',
},
}),
);
});
it('should return all plugins from sentryVitePlugin', async () => {
const plugins = await makeCustomSentryVitePlugins({});
expect(plugins).toHaveLength(1);
expect(plugins?.[0]?.name).toBe('sentry-vite-plugin');
});
it('should disable sourcemap upload by default', async () => {
await makeCustomSentryVitePlugins({});
expect(sentryVitePlugin).toHaveBeenCalledWith(
expect.objectContaining({
sourcemaps: expect.objectContaining({
disable: true,
}),
}),
);
});
it('should allow overriding sourcemaps via unstable_sentryVitePluginOptions', async () => {
await makeCustomSentryVitePlugins({
unstable_sentryVitePluginOptions: {
sourcemaps: {
assets: ['dist/**'],
},
},
});
// unstable_sentryVitePluginOptions is spread last, so it fully overrides sourcemaps
expect(sentryVitePlugin).toHaveBeenCalledWith(
expect.objectContaining({
sourcemaps: {
assets: ['dist/**'],
},
}),
);
});
});