1
- import { vi } from 'vitest' ;
2
-
3
1
import { sentrySvelteKitPlugin } from './../../src/vite/sentrySvelteKitPlugin' ;
4
- import * as utils from './../../src/vite/utils' ;
5
2
6
3
describe ( 'sentrySvelteKitPlugin' , ( ) => {
7
4
it ( 'returns a Vite plugin with name, enforce, and config hook' , ( ) => {
@@ -12,97 +9,4 @@ describe('sentrySvelteKitPlugin', () => {
12
9
expect ( plugin . name ) . toEqual ( 'sentry-sveltekit' ) ;
13
10
expect ( plugin . enforce ) . toEqual ( 'pre' ) ;
14
11
} ) ;
15
-
16
- describe ( 'config hook' , ( ) => {
17
- const hasSentryInitFilesSpy = vi . spyOn ( utils , 'hasSentryInitFiles' ) . mockReturnValue ( true ) ;
18
-
19
- beforeEach ( ( ) => {
20
- hasSentryInitFilesSpy . mockClear ( ) ;
21
- } ) ;
22
-
23
- it ( 'adds the injectInitPlugin and adjusts the dev server config if init config files exist' , ( ) => {
24
- const plugin = sentrySvelteKitPlugin ( ) ;
25
- const originalConfig = { } ;
26
-
27
- // @ts -ignore - plugin.config exists and is callable
28
- const modifiedConfig = plugin . config ( originalConfig ) ;
29
-
30
- expect ( modifiedConfig ) . toEqual ( {
31
- plugins : [
32
- {
33
- enforce : 'pre' ,
34
- name : 'sentry-init-injection-plugin' ,
35
- transform : expect . any ( Function ) ,
36
- } ,
37
- ] ,
38
- server : {
39
- fs : {
40
- allow : [ '.' ] ,
41
- } ,
42
- } ,
43
- } ) ;
44
- expect ( hasSentryInitFilesSpy ) . toHaveBeenCalledTimes ( 1 ) ;
45
- } ) ;
46
-
47
- it ( 'merges user-defined options with Sentry-specifc ones' , ( ) => {
48
- const plugin = sentrySvelteKitPlugin ( ) ;
49
- const originalConfig = {
50
- test : {
51
- include : [ 'src/**/*.{test,spec}.{js,ts}' ] ,
52
- } ,
53
- build : {
54
- sourcemap : 'css' ,
55
- } ,
56
- plugins : [ { name : 'some plugin' } ] ,
57
- server : {
58
- fs : {
59
- allow : [ './build/**/*.{js}' ] ,
60
- } ,
61
- } ,
62
- } ;
63
-
64
- // @ts -ignore - plugin.config exists and is callable
65
- const modifiedConfig = plugin . config ( originalConfig ) ;
66
-
67
- expect ( modifiedConfig ) . toEqual ( {
68
- test : {
69
- include : [ 'src/**/*.{test,spec}.{js,ts}' ] ,
70
- } ,
71
- build : {
72
- sourcemap : 'css' ,
73
- } ,
74
- plugins : [
75
- {
76
- enforce : 'pre' ,
77
- name : 'sentry-init-injection-plugin' ,
78
- transform : expect . any ( Function ) ,
79
- } ,
80
- { name : 'some plugin' } ,
81
- ] ,
82
- server : {
83
- fs : {
84
- allow : [ './build/**/*.{js}' , '.' ] ,
85
- } ,
86
- } ,
87
- } ) ;
88
- expect ( hasSentryInitFilesSpy ) . toHaveBeenCalledTimes ( 1 ) ;
89
- } ) ;
90
-
91
- it ( "doesn't add the injectInitPlugin if init config files don't exist" , ( ) => {
92
- hasSentryInitFilesSpy . mockReturnValue ( false ) ;
93
- const plugin = sentrySvelteKitPlugin ( ) ;
94
- const originalConfig = {
95
- plugins : [ { name : 'some plugin' } ] ,
96
- } ;
97
-
98
- // @ts -ignore - plugin.config exists and is callable
99
- const modifiedConfig = plugin . config ( originalConfig ) ;
100
-
101
- expect ( modifiedConfig ) . toEqual ( {
102
- plugins : [ { name : 'some plugin' } ] ,
103
- server : { } ,
104
- } ) ;
105
- expect ( hasSentryInitFilesSpy ) . toHaveBeenCalledTimes ( 1 ) ;
106
- } ) ;
107
- } ) ;
108
12
} ) ;
0 commit comments