@@ -27,7 +27,8 @@ const userNextConfig = {
27
27
} ) ,
28
28
} ) ,
29
29
} ;
30
- const userSentryWebpackPluginConfig = { org : 'squirrelChasers' , project : 'simulator' , include : './thirdPartyMaps' } ;
30
+ const userSentryWebpackPluginConfig = { org : 'squirrelChasers' , project : 'simulator' } ;
31
+ process . env . SENTRY_AUTH_TOKEN = 'dogsarebadatkeepingsecrets' ;
31
32
32
33
/** Mocks of the arguments passed to the result of `withSentryConfig` (when it's a function). */
33
34
const runtimePhase = 'ball-fetching' ;
@@ -115,7 +116,7 @@ function materializeFinalNextConfig(
115
116
*/
116
117
async function materializeFinalWebpackConfig ( options : {
117
118
userNextConfig : ExportedNextConfig ;
118
- userSentryWebpackPluginConfig ?: SentryWebpackPluginOptions ;
119
+ userSentryWebpackPluginConfig ?: Partial < SentryWebpackPluginOptions > ;
119
120
incomingWebpackConfig : WebpackConfigObject ;
120
121
incomingWebpackBuildContext : BuildContext ;
121
122
} ) : Promise < WebpackConfigObject > {
@@ -292,12 +293,45 @@ describe('webpack config', () => {
292
293
} ) ;
293
294
294
295
describe ( 'Sentry webpack plugin config' , ( ) => {
295
- it ( 'includes expected properties' , ( ) => {
296
- // TODO
296
+ it ( 'includes expected properties' , async ( ) => {
297
+ // also, can pull from either env or user config (see notes on specific properties below)
298
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
299
+ userNextConfig,
300
+ userSentryWebpackPluginConfig,
301
+ incomingWebpackConfig : serverWebpackConfig ,
302
+ incomingWebpackBuildContext : serverBuildContext ,
303
+ } ) ;
304
+
305
+ expect ( finalWebpackConfig . plugins ?. [ 0 ] . options ) . toEqual (
306
+ expect . objectContaining ( {
307
+ include : [
308
+ // because this is the server build
309
+ { path : '.next/server/chunks/' , urlPrefix : '~/_next/server/chunks' } ,
310
+ { path : '.next/server/pages/' , urlPrefix : '~/_next/server/pages' } ,
311
+ { path : '.next/serverless/' , urlPrefix : '~/_next/serverless' } ,
312
+ ] ,
313
+ ignore : [ ] , // default
314
+ org : 'squirrelChasers' , // from user webpack plugin config
315
+ project : 'simulator' , // from user webpack plugin config
316
+ authToken : 'dogsarebadatkeepingsecrets' , // picked up from env
317
+ stripPrefix : [ 'webpack://_N_E/' ] , // default
318
+ urlPrefix : `~/_next` , // default
319
+ entries : expect . any ( Function ) , // default, tested separately elsewhere
320
+ release : 'doGsaREgReaT' , // from build context
321
+ dryRun : false , // based on buildContext.dev being false
322
+ } ) ,
323
+ ) ;
297
324
} ) ;
298
325
299
- it ( 'preserves unrelated plugin config options' , ( ) => {
300
- // TODO
326
+ it ( 'preserves unrelated plugin config options' , async ( ) => {
327
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
328
+ userNextConfig,
329
+ userSentryWebpackPluginConfig : { ...userSentryWebpackPluginConfig , debug : true } ,
330
+ incomingWebpackConfig : serverWebpackConfig ,
331
+ incomingWebpackBuildContext : serverBuildContext ,
332
+ } ) ;
333
+
334
+ expect ( ( finalWebpackConfig . plugins ?. [ 0 ] . options as SentryWebpackPluginOptions ) . debug ) . toEqual ( true ) ;
301
335
} ) ;
302
336
303
337
it ( 'warns when overriding certain default values' , ( ) => {
0 commit comments