-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsentrySolidStartVite.test.ts
More file actions
55 lines (48 loc) · 1.86 KB
/
sentrySolidStartVite.test.ts
File metadata and controls
55 lines (48 loc) · 1.86 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
import type { Plugin } from 'vite';
import { describe, expect, it, vi } from 'vitest';
import { sentrySolidStartVite } from '../../src/vite/sentrySolidStartVite';
vi.spyOn(console, 'log').mockImplementation(() => {
/* noop */
});
vi.spyOn(console, 'warn').mockImplementation(() => {
/* noop */
});
function getSentrySolidStartVitePlugins(options?: Parameters<typeof sentrySolidStartVite>[0]): Plugin[] {
return sentrySolidStartVite(
{
project: 'project',
org: 'org',
authToken: 'token',
...options,
},
{},
);
}
describe('sentrySolidStartVite()', () => {
it('returns an array of vite plugins', () => {
const plugins = getSentrySolidStartVitePlugins();
const names = plugins.map(plugin => plugin.name);
expect(names).toEqual([
'sentry-solidstart-build-instrumentation-file',
'sentry-telemetry-plugin',
'sentry-vite-injection-plugin',
'sentry-release-management-plugin',
'sentry-vite-debug-id-upload-plugin',
'sentry-file-deletion-plugin',
'sentry-solidstart-update-source-map-setting',
]);
});
it("returns only build-instrumentation-file plugin if source maps upload isn't enabled", () => {
const plugins = getSentrySolidStartVitePlugins({ sourceMapsUploadOptions: { enabled: false } });
const names = plugins.map(plugin => plugin.name);
expect(names).toEqual(['sentry-solidstart-build-instrumentation-file']);
});
it('returns only build-instrumentation-file plugin if `NODE_ENV` is development', async () => {
const previousEnv = process.env.NODE_ENV;
process.env.NODE_ENV = 'development';
const plugins = getSentrySolidStartVitePlugins({ sourceMapsUploadOptions: { enabled: true } });
const names = plugins.map(plugin => plugin.name);
expect(names).toEqual(['sentry-solidstart-build-instrumentation-file']);
process.env.NODE_ENV = previousEnv;
});
});