@@ -36,59 +36,73 @@ describe('sentryTanstackStart()', () => {
3636 process . env . NODE_ENV = 'production' ;
3737 } ) ;
3838
39- it ( 'returns plugins in production mode' , ( ) => {
40- const plugins = sentryTanstackStart ( { org : 'test-org' } ) ;
39+ describe ( 'middleware auto-instrumentation' , ( ) => {
40+ it ( 'adds middleware plugin by default' , ( ) => {
41+ process . env . NODE_ENV = 'development' ;
42+ const plugins = sentryTanstackStart ( { } ) ;
4143
42- expect ( plugins . length ) . toBeGreaterThan ( 0 ) ;
43- } ) ;
44+ expect ( plugins ) . toHaveLength ( 1 ) ;
45+ expect ( plugins . find ( p => p . name === 'sentry-tanstack-middleware-auto-instrument' ) ) . toBeDefined ( ) ;
46+ } ) ;
4447
45- it ( 'returns no plugins in development mode' , ( ) => {
46- process . env . NODE_ENV = 'development' ;
48+ it ( 'adds middleware plugin when autoInstrumentMiddleware is true' , ( ) => {
49+ process . env . NODE_ENV = 'development' ;
50+ const plugins = sentryTanstackStart ( { autoInstrumentMiddleware : true } ) ;
4751
48- const plugins = sentryTanstackStart ( { org : 'test-org' } ) ;
52+ expect ( plugins ) . toHaveLength ( 1 ) ;
53+ expect ( plugins . find ( p => p . name === 'sentry-tanstack-middleware-auto-instrument' ) ) . toBeDefined ( ) ;
54+ } ) ;
4955
50- expect ( plugins ) . toHaveLength ( 0 ) ;
51- } ) ;
56+ it ( 'does not add middleware plugin when autoInstrumentMiddleware is false' , ( ) => {
57+ process . env . NODE_ENV = 'development' ;
58+ const plugins = sentryTanstackStart ( { autoInstrumentMiddleware : false } ) ;
5259
53- it ( 'returns Sentry Vite plugins but not enable source maps plugin when sourcemaps.disable is true' , ( ) => {
54- const plugins = sentryTanstackStart ( {
55- sourcemaps : { disable : true } ,
60+ expect ( plugins ) . toHaveLength ( 0 ) ;
5661 } ) ;
57-
58- expect ( plugins ) . toHaveLength ( 2 ) ;
59- expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-source-maps-config' ) ) . toBeDefined ( ) ;
60- expect ( plugins . find ( p => p . name === 'sentry-vite-debug-id-upload-plugin' ) ) . toBeDefined ( ) ;
61- expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-react-source-maps' ) ) . toBeUndefined ( ) ;
6262 } ) ;
6363
64- it ( 'returns Sentry Vite plugins but not enable source maps plugin when sourcemaps.disable is "disable-upload"' , ( ) => {
65- const plugins = sentryTanstackStart ( {
66- sourcemaps : { disable : 'disable-upload' } ,
64+ describe ( 'source maps' , ( ) => {
65+ it ( 'returns Sentry Vite plugins but not enable source maps plugin when sourcemaps.disable is true' , ( ) => {
66+ const plugins = sentryTanstackStart ( {
67+ autoInstrumentMiddleware : false ,
68+ sourcemaps : { disable : true } ,
69+ } ) ;
70+
71+ expect ( plugins ) . toHaveLength ( 2 ) ;
72+ expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-source-maps-config' ) ) . toBeDefined ( ) ;
73+ expect ( plugins . find ( p => p . name === 'sentry-vite-debug-id-upload-plugin' ) ) . toBeDefined ( ) ;
74+ expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-react-source-maps' ) ) . toBeUndefined ( ) ;
6775 } ) ;
6876
69- expect ( plugins ) . toHaveLength ( 2 ) ;
70- expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-source-maps-config' ) ) . toBeDefined ( ) ;
71- expect ( plugins . find ( p => p . name === 'sentry-vite-debug-id-upload-plugin' ) ) . toBeDefined ( ) ;
72- expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-react-source-maps' ) ) . toBeUndefined ( ) ;
73- } ) ;
77+ it ( 'returns Sentry Vite plugins but not enable source maps plugin when sourcemaps.disable is "disable-upload"' , ( ) => {
78+ const plugins = sentryTanstackStart ( {
79+ autoInstrumentMiddleware : false ,
80+ sourcemaps : { disable : 'disable-upload' } ,
81+ } ) ;
7482
75- it ( 'returns Sentry Vite plugins and enable source maps plugin when sourcemaps.disable is false' , ( ) => {
76- const plugins = sentryTanstackStart ( {
77- sourcemaps : { disable : false } ,
83+ expect ( plugins ) . toHaveLength ( 2 ) ;
84+ expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-source-maps-config' ) ) . toBeDefined ( ) ;
85+ expect ( plugins . find ( p => p . name === 'sentry-vite-debug-id-upload-plugin' ) ) . toBeDefined ( ) ;
86+ expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-react-source-maps' ) ) . toBeUndefined ( ) ;
7887 } ) ;
7988
80- expect ( plugins ) . toHaveLength ( 3 ) ;
81- expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-source-maps-config' ) ) . toBeDefined ( ) ;
82- expect ( plugins . find ( p => p . name === 'sentry-vite-debug-id-upload-plugin' ) ) . toBeDefined ( ) ;
83- expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-react-source-maps' ) ) . toBeDefined ( ) ;
84- } ) ;
89+ it ( 'returns Sentry Vite plugins and enable source maps plugin when sourcemaps.disable is false' , ( ) => {
90+ const plugins = sentryTanstackStart ( {
91+ autoInstrumentMiddleware : false ,
92+ sourcemaps : { disable : false } ,
93+ } ) ;
8594
86- it ( 'returns Sentry Vite Plugins and enable source maps plugin by default when sourcemaps is not specified' , ( ) => {
87- const plugins = sentryTanstackStart ( { } ) ;
95+ expect ( plugins ) . toHaveLength ( 3 ) ;
96+ expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-source-maps-config' ) ) . toBeDefined ( ) ;
97+ expect ( plugins . find ( p => p . name === 'sentry-vite-debug-id-upload-plugin' ) ) . toBeDefined ( ) ;
98+ expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-react-source-maps' ) ) . toBeDefined ( ) ;
99+ } ) ;
88100
89- expect ( plugins ) . toHaveLength ( 3 ) ;
90- expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-source-maps-config' ) ) . toBeDefined ( ) ;
91- expect ( plugins . find ( p => p . name === 'sentry-vite-debug-id-upload-plugin' ) ) . toBeDefined ( ) ;
92- expect ( plugins . find ( p => p . name === 'sentry-tanstackstart-react-source-maps' ) ) . toBeDefined ( ) ;
101+ it ( 'returns no source maps plugins in development mode' , ( ) => {
102+ process . env . NODE_ENV = 'development' ;
103+ const plugins = sentryTanstackStart ( { autoInstrumentMiddleware : false } ) ;
104+
105+ expect ( plugins ) . toHaveLength ( 0 ) ;
106+ } ) ;
93107 } ) ;
94108} ) ;
0 commit comments