1- import * as isBuildModule from '../../src/utils/isBuild' ;
2- import { defaultsObject , exportedNextConfig , runtimePhase , userNextConfig } from './fixtures' ;
1+ import { defaultRuntimePhase , defaultsObject , exportedNextConfig , userNextConfig } from './fixtures' ;
32import { materializeFinalNextConfig } from './testUtils' ;
43
5- const isBuildSpy = jest . spyOn ( isBuildModule , 'isBuild' ) . mockReturnValue ( true ) ;
6-
74describe ( 'withSentryConfig' , ( ) => {
85 it ( 'includes expected properties' , ( ) => {
96 const finalConfig = materializeFinalNextConfig ( exportedNextConfig ) ;
@@ -50,7 +47,7 @@ describe('withSentryConfig', () => {
5047
5148 materializeFinalNextConfig ( exportedNextConfigFunction ) ;
5249
53- expect ( exportedNextConfigFunction ) . toHaveBeenCalledWith ( runtimePhase , defaultsObject ) ;
50+ expect ( exportedNextConfigFunction ) . toHaveBeenCalledWith ( defaultRuntimePhase , defaultsObject ) ;
5451 } ) ;
5552
5653 it ( 'removes `sentry` property' , ( ) => {
@@ -71,25 +68,34 @@ describe('withSentryConfig', () => {
7168 // time, but the spy belongs to the first instance of the module and therefore never registers a call. Thus we have
7269 // to test whether or not the file is required instead.
7370
74- it ( 'imports from `webpack.ts` if `isBuild` returns true ' , ( ) => {
71+ it ( 'imports from `webpack.ts` if build phase is "phase-production-build" ' , ( ) => {
7572 jest . isolateModules ( ( ) => {
7673 // In case this is still set from elsewhere, reset it
7774 delete ( global as any ) . _sentryWebpackModuleLoaded ;
7875
79- materializeFinalNextConfig ( exportedNextConfig ) ;
76+ materializeFinalNextConfig ( exportedNextConfig , undefined , 'phase-production-build' ) ;
8077
8178 expect ( ( global as any ) . _sentryWebpackModuleLoaded ) . toBe ( true ) ;
8279 } ) ;
8380 } ) ;
8481
85- it ( "doesn't import from `webpack.ts` if `isBuild` returns false" , ( ) => {
82+ it ( 'imports from `webpack.ts` if build phase is "phase-development-server"' , ( ) => {
8683 jest . isolateModules ( ( ) => {
87- isBuildSpy . mockReturnValueOnce ( false ) ;
84+ // In case this is still set from elsewhere, reset it
85+ delete ( global as any ) . _sentryWebpackModuleLoaded ;
8886
87+ materializeFinalNextConfig ( exportedNextConfig , undefined , 'phase-production-build' ) ;
88+
89+ expect ( ( global as any ) . _sentryWebpackModuleLoaded ) . toBe ( true ) ;
90+ } ) ;
91+ } ) ;
92+
93+ it ( 'Doesn\'t import from `webpack.ts` if build phase is "phase-production-server"' , ( ) => {
94+ jest . isolateModules ( ( ) => {
8995 // In case this is still set from elsewhere, reset it
9096 delete ( global as any ) . _sentryWebpackModuleLoaded ;
9197
92- materializeFinalNextConfig ( exportedNextConfig ) ;
98+ materializeFinalNextConfig ( exportedNextConfig , undefined , 'phase-production-server' ) ;
9399
94100 expect ( ( global as any ) . _sentryWebpackModuleLoaded ) . toBeUndefined ( ) ;
95101 } ) ;
0 commit comments