@@ -35,6 +35,70 @@ describe('valueInjectionLoader', () => {
35
35
expect ( result ) . toMatch ( ';globalThis["foo"] = "bar";' ) ;
36
36
} ) ;
37
37
38
+ it ( 'should work with instrumentation-client.js files' , ( ) => {
39
+ const instrumentationLoaderThis = {
40
+ ...loaderThis ,
41
+ resourcePath : './instrumentation-client.js' ,
42
+ } ;
43
+
44
+ const userCode = `
45
+ import * as Sentry from '@sentry/nextjs';
46
+ Sentry.init();
47
+ ` ;
48
+
49
+ const result = valueInjectionLoader . call ( instrumentationLoaderThis , userCode ) ;
50
+
51
+ expect ( result ) . toMatch ( ';globalThis["foo"] = "bar";' ) ;
52
+ } ) ;
53
+
54
+ it ( 'should work with instrumentation-client.ts files' , ( ) => {
55
+ const instrumentationLoaderThis = {
56
+ ...loaderThis ,
57
+ resourcePath : './instrumentation-client.ts' ,
58
+ } ;
59
+
60
+ const userCode = `
61
+ import * as Sentry from '@sentry/nextjs';
62
+ Sentry.init();
63
+ ` ;
64
+
65
+ const result = valueInjectionLoader . call ( instrumentationLoaderThis , userCode ) ;
66
+
67
+ expect ( result ) . toMatch ( ';globalThis["foo"] = "bar";' ) ;
68
+ } ) ;
69
+
70
+ it ( 'should work with src/instrumentation-client.js files' , ( ) => {
71
+ const instrumentationLoaderThis = {
72
+ ...loaderThis ,
73
+ resourcePath : './src/instrumentation-client.js' ,
74
+ } ;
75
+
76
+ const userCode = `
77
+ import * as Sentry from '@sentry/nextjs';
78
+ Sentry.init();
79
+ ` ;
80
+
81
+ const result = valueInjectionLoader . call ( instrumentationLoaderThis , userCode ) ;
82
+
83
+ expect ( result ) . toMatch ( ';globalThis["foo"] = "bar";' ) ;
84
+ } ) ;
85
+
86
+ it ( 'should work with src/instrumentation-client.ts files' , ( ) => {
87
+ const instrumentationLoaderThis = {
88
+ ...loaderThis ,
89
+ resourcePath : './src/instrumentation-client.ts' ,
90
+ } ;
91
+
92
+ const userCode = `
93
+ import * as Sentry from '@sentry/nextjs';
94
+ Sentry.init();
95
+ ` ;
96
+
97
+ const result = valueInjectionLoader . call ( instrumentationLoaderThis , userCode ) ;
98
+
99
+ expect ( result ) . toMatch ( ';globalThis["foo"] = "bar";' ) ;
100
+ } ) ;
101
+
38
102
it ( 'should correctly insert values with directive' , ( ) => {
39
103
const userCode = `
40
104
"use client"
0 commit comments