@@ -57,11 +57,10 @@ afterAll(() => {
57
57
// In order to know what to expect in the webpack config `entry` property, we need to know the path of the temporary
58
58
// directory created when doing the file injection, so wrap the real `mkdtempSync` and store the resulting path where we
59
59
// can access it
60
- let tempDir : string ;
61
- const realMkdtempSync = jest . requireActual ( 'fs' ) . mkdtempSync ;
62
- jest . spyOn ( fs , 'mkdtempSync' ) . mockImplementation ( prefix => {
63
- tempDir = realMkdtempSync ( prefix ) ;
64
- return tempDir ;
60
+ const mkdtempSyncSpy = jest . spyOn ( fs , 'mkdtempSync' ) ;
61
+
62
+ afterEach ( ( ) => {
63
+ mkdtempSyncSpy . mockClear ( ) ;
65
64
} ) ;
66
65
67
66
/** Mocks of the arguments passed to `withSentryConfig` */
@@ -311,6 +310,7 @@ describe('webpack config', () => {
311
310
incomingWebpackBuildContext : serverBuildContext ,
312
311
} ) ;
313
312
313
+ const tempDir = mkdtempSyncSpy . mock . results [ 0 ] . value ;
314
314
const rewriteFramesHelper = path . join ( tempDir , 'rewriteFramesHelper.js' ) ;
315
315
316
316
expect ( finalWebpackConfig . entry ) . toEqual (
@@ -405,6 +405,8 @@ describe('webpack config', () => {
405
405
incomingWebpackConfig : serverWebpackConfig ,
406
406
incomingWebpackBuildContext : getBuildContext ( 'server' , userNextConfigDistDir ) ,
407
407
} ) ;
408
+
409
+ const tempDir = mkdtempSyncSpy . mock . results [ 0 ] . value ;
408
410
const rewriteFramesHelper = path . join ( tempDir , 'rewriteFramesHelper.js' ) ;
409
411
410
412
expect ( fs . existsSync ( rewriteFramesHelper ) ) . toBe ( true ) ;
@@ -668,6 +670,8 @@ describe('Sentry webpack plugin config', () => {
668
670
} ) ;
669
671
670
672
describe ( 'getUserConfigFile' , ( ) => {
673
+ let tempDir : string ;
674
+
671
675
beforeAll ( ( ) => {
672
676
exitsSync . mockImplementation ( realExistsSync ) ;
673
677
} ) ;
@@ -677,6 +681,7 @@ describe('Sentry webpack plugin config', () => {
677
681
// that the location of the created folder is stored in `tempDir`
678
682
const tempDirPathPrefix = path . join ( os . tmpdir ( ) , 'sentry-nextjs-test-' ) ;
679
683
fs . mkdtempSync ( tempDirPathPrefix ) ;
684
+ tempDir = mkdtempSyncSpy . mock . results [ 0 ] . value ;
680
685
} ) ;
681
686
682
687
afterAll ( ( ) => {
0 commit comments