diff --git a/packages/mui-icons-material/builder.test.mjs b/packages/mui-icons-material/builder.test.mjs index c12d9c27b79645..9d4bc2f80c41ad 100644 --- a/packages/mui-icons-material/builder.test.mjs +++ b/packages/mui-icons-material/builder.test.mjs @@ -44,15 +44,27 @@ describe('builder', () => { }; // eslint-disable-next-line mocha/handle-done-callback - beforeEach(async function beforeEachHook(ctx) { - // DON'T CLEAN UP TO MAKE TEST INSPECTABLE - options.outputDir = path.join( - os.tmpdir(), - 'material-ui-icons-builder-test', - process.env.VITEST ? ctx.task.name : this.currentTest.fullTitle(), - ); - await fse.emptyDir(options.outputDir); - }); + beforeEach( + process.env.VITEST + ? async function beforeEachHook(ctx) { + // DON'T CLEAN UP TO MAKE TEST INSPECTABLE + options.outputDir = path.join( + os.tmpdir(), + 'material-ui-icons-builder-test', + ctx.task.name, + ); + await fse.emptyDir(options.outputDir); + } + : async function beforeEachHook() { + // DON'T CLEAN UP TO MAKE TEST INSPECTABLE + options.outputDir = path.join( + os.tmpdir(), + 'material-ui-icons-builder-test', + this.currentTest.fullTitle(), + ); + await fse.emptyDir(options.outputDir); + }, + ); it('script outputs to directory', async () => { await handler(options);