|
1 | | -import { beforeEach, describe, it, vi } from 'vitest'; |
2 | | -import type { Nitro } from '../../build/types/config/types'; |
| 1 | +import type { Plugin } from 'vite'; |
| 2 | +import { beforeEach, describe, expect, it, vi } from 'vitest'; |
| 3 | +import type { Nitro } from '../../src/config'; |
3 | 4 | import { withSentry } from '../../src/config'; |
4 | 5 |
|
5 | 6 | const userDefinedNitroRollupBeforeHookMock = vi.fn(); |
@@ -62,4 +63,84 @@ describe('withSentry()', () => { |
62 | 63 | expect(experimental_addInstrumentationFileTopLevelImportToServerEntryMock).not.toHaveBeenCalled(); |
63 | 64 | expect(userDefinedNitroCloseHookMock).toHaveBeenCalled(); |
64 | 65 | }); |
| 66 | + |
| 67 | + it('adds the sentry solidstart vite plugin', () => { |
| 68 | + const config = withSentry(solidStartConfig, { |
| 69 | + project: 'project', |
| 70 | + org: 'org', |
| 71 | + authToken: 'token', |
| 72 | + }); |
| 73 | + const names = config?.vite.plugins.flat().map((plugin: Plugin) => plugin.name); |
| 74 | + expect(names).toEqual([ |
| 75 | + 'sentry-solidstart-source-maps', |
| 76 | + 'sentry-telemetry-plugin', |
| 77 | + 'sentry-vite-release-injection-plugin', |
| 78 | + 'sentry-debug-id-upload-plugin', |
| 79 | + 'sentry-vite-debug-id-injection-plugin', |
| 80 | + 'sentry-vite-debug-id-upload-plugin', |
| 81 | + 'sentry-file-deletion-plugin', |
| 82 | + 'sentry-solidstart-build-instrumentation-file', |
| 83 | + ]); |
| 84 | + }); |
| 85 | + |
| 86 | + it('extends the passed in vite config object', () => { |
| 87 | + const config = withSentry( |
| 88 | + { |
| 89 | + ...solidStartConfig, |
| 90 | + vite: { |
| 91 | + plugins: [{ name: 'my-test-plugin' }], |
| 92 | + }, |
| 93 | + }, |
| 94 | + { |
| 95 | + project: 'project', |
| 96 | + org: 'org', |
| 97 | + authToken: 'token', |
| 98 | + }, |
| 99 | + ); |
| 100 | + |
| 101 | + const names = config?.vite.plugins.flat().map((plugin: Plugin) => plugin.name); |
| 102 | + expect(names).toEqual([ |
| 103 | + 'sentry-solidstart-source-maps', |
| 104 | + 'sentry-telemetry-plugin', |
| 105 | + 'sentry-vite-release-injection-plugin', |
| 106 | + 'sentry-debug-id-upload-plugin', |
| 107 | + 'sentry-vite-debug-id-injection-plugin', |
| 108 | + 'sentry-vite-debug-id-upload-plugin', |
| 109 | + 'sentry-file-deletion-plugin', |
| 110 | + 'sentry-solidstart-build-instrumentation-file', |
| 111 | + 'my-test-plugin', |
| 112 | + ]); |
| 113 | + }); |
| 114 | + |
| 115 | + it('extends the passed in vite function config', () => { |
| 116 | + const config = withSentry( |
| 117 | + { |
| 118 | + ...solidStartConfig, |
| 119 | + vite() { |
| 120 | + return { plugins: [{ name: 'my-test-plugin' }] }; |
| 121 | + }, |
| 122 | + }, |
| 123 | + { |
| 124 | + project: 'project', |
| 125 | + org: 'org', |
| 126 | + authToken: 'token', |
| 127 | + }, |
| 128 | + ); |
| 129 | + |
| 130 | + const names = config |
| 131 | + ?.vite() |
| 132 | + .plugins.flat() |
| 133 | + .map((plugin: Plugin) => plugin.name); |
| 134 | + expect(names).toEqual([ |
| 135 | + 'sentry-solidstart-source-maps', |
| 136 | + 'sentry-telemetry-plugin', |
| 137 | + 'sentry-vite-release-injection-plugin', |
| 138 | + 'sentry-debug-id-upload-plugin', |
| 139 | + 'sentry-vite-debug-id-injection-plugin', |
| 140 | + 'sentry-vite-debug-id-upload-plugin', |
| 141 | + 'sentry-file-deletion-plugin', |
| 142 | + 'sentry-solidstart-build-instrumentation-file', |
| 143 | + 'my-test-plugin', |
| 144 | + ]); |
| 145 | + }); |
65 | 146 | }); |
0 commit comments