| 
 | 1 | +import type { Plugin } from 'vite';  | 
 | 2 | +import { describe, expect, it, vi } from 'vitest';  | 
 | 3 | +import { sentrySolidStartVite } from '../../src/vite/sentrySolidStartVite';  | 
 | 4 | + | 
 | 5 | +vi.spyOn(console, 'log').mockImplementation(() => {  | 
 | 6 | +  /* noop */  | 
 | 7 | +});  | 
 | 8 | +vi.spyOn(console, 'warn').mockImplementation(() => {  | 
 | 9 | +  /* noop */  | 
 | 10 | +});  | 
 | 11 | + | 
 | 12 | +function getSentrySolidStartVitePlugins(options?: Parameters<typeof sentrySolidStartVite>[0]): Plugin[] {  | 
 | 13 | +  return sentrySolidStartVite({  | 
 | 14 | +    sourceMapsUploadOptions: {  | 
 | 15 | +      authToken: 'token',  | 
 | 16 | +      org: 'org',  | 
 | 17 | +      project: 'project',  | 
 | 18 | +      ...options?.sourceMapsUploadOptions,  | 
 | 19 | +    },  | 
 | 20 | +    ...options,  | 
 | 21 | +  });  | 
 | 22 | +}  | 
 | 23 | + | 
 | 24 | +describe('sentrySolidStartVite()', () => {  | 
 | 25 | +  it('returns an array of vite plugins', () => {  | 
 | 26 | +    const plugins = getSentrySolidStartVitePlugins();  | 
 | 27 | +    const names = plugins.map(plugin => plugin.name);  | 
 | 28 | +    expect(names).toEqual([  | 
 | 29 | +      'sentry-solidstart-source-maps',  | 
 | 30 | +      'sentry-telemetry-plugin',  | 
 | 31 | +      'sentry-vite-release-injection-plugin',  | 
 | 32 | +      'sentry-debug-id-upload-plugin',  | 
 | 33 | +      'sentry-vite-debug-id-injection-plugin',  | 
 | 34 | +      'sentry-file-deletion-plugin',  | 
 | 35 | +      'sentry-vite-debug-id-upload-plugin',  | 
 | 36 | +    ]);  | 
 | 37 | +  });  | 
 | 38 | + | 
 | 39 | +  it("returns an empty array if source maps upload isn't enabled", () => {  | 
 | 40 | +    const plugins = getSentrySolidStartVitePlugins({ sourceMapsUploadOptions: { enabled: false } });  | 
 | 41 | +    expect(plugins).toHaveLength(0);  | 
 | 42 | +  });  | 
 | 43 | + | 
 | 44 | +  it('returns an empty array if `NODE_ENV` is development', async () => {  | 
 | 45 | +    const previousEnv = process.env.NODE_ENV;  | 
 | 46 | +    process.env.NODE_ENV = 'development';  | 
 | 47 | + | 
 | 48 | +    const plugins = getSentrySolidStartVitePlugins({ sourceMapsUploadOptions: { enabled: true } });  | 
 | 49 | +    expect(plugins).toHaveLength(0);  | 
 | 50 | + | 
 | 51 | +    process.env.NODE_ENV = previousEnv;  | 
 | 52 | +  });  | 
 | 53 | +});  | 
0 commit comments