-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathmakeCustomSentryVitePlugins.test.ts
More file actions
84 lines (72 loc) · 2.73 KB
/
makeCustomSentryVitePlugins.test.ts
File metadata and controls
84 lines (72 loc) · 2.73 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
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-telemetry-plugin' },
{ name: 'sentry-vite-injection-plugin' },
{ name: 'sentry-vite-component-name-annotate-plugin' },
{ name: 'other-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 only return telemetry and release injection plugins', async () => {
const plugins = await makeCustomSentryVitePlugins({});
expect(plugins).toHaveLength(2);
expect(plugins?.[0]?.name).toBe('sentry-telemetry-plugin');
expect(plugins?.[1]?.name).toBe('sentry-vite-injection-plugin');
});
it('should include component annotation plugin when reactComponentAnnotation.enabled is true', async () => {
const plugins = await makeCustomSentryVitePlugins({ reactComponentAnnotation: { enabled: true } });
expect(plugins).toHaveLength(3);
expect(plugins?.[0]?.name).toBe('sentry-telemetry-plugin');
expect(plugins?.[1]?.name).toBe('sentry-vite-injection-plugin');
expect(plugins?.[2]?.name).toBe('sentry-vite-component-name-annotate-plugin');
});
it('should include component annotation plugin when unstable_sentryVitePluginOptions.reactComponentAnnotation.enabled is true', async () => {
const plugins = await makeCustomSentryVitePlugins({
unstable_sentryVitePluginOptions: { reactComponentAnnotation: { enabled: true } },
});
expect(plugins).toHaveLength(3);
expect(plugins?.[0]?.name).toBe('sentry-telemetry-plugin');
expect(plugins?.[1]?.name).toBe('sentry-vite-injection-plugin');
expect(plugins?.[2]?.name).toBe('sentry-vite-component-name-annotate-plugin');
});
});