diff --git a/packages/rspack-test-tools/tests/compilerCases/compare-before-emit-disable.js b/packages/rspack-test-tools/tests/compilerCases/compare-before-emit-disable.js index c87ce9f41fc..f5c738f69fa 100644 --- a/packages/rspack-test-tools/tests/compilerCases/compare-before-emit-disable.js +++ b/packages/rspack-test-tools/tests/compilerCases/compare-before-emit-disable.js @@ -6,31 +6,37 @@ let first_asset_mtime; /** @type {import('../../dist').TCompilerCaseConfig} */ module.exports = { - description: "should write same content to same file", - options(context) { - return { - output: { - path: context.getDist(), - filename: "main.js", - compareBeforeEmit: false - }, - context: context.getSource(), - entry: "./d", - }; - }, - async build(context, compiler) { - rimrafSync(context.getDist()); - await new Promise(resolve => { - compiler.run(() => { - first_asset_mtime = fs.statSync(path.join(context.getDist("main.js")))?.mtime; - compiler.run(() => { - resolve(); - }); - }); - }); - }, - async check(context) { - let second_asset_mtime = fs.statSync(path.join(context.getDist("main.js")))?.mtime; - expect(first_asset_mtime).not.toEqual(second_asset_mtime); - } + description: "should write same content to same file", + options(context) { + return { + output: { + path: context.getDist(), + filename: "main.js", + compareBeforeEmit: false + }, + context: context.getSource(), + entry: "./d" + }; + }, + async build(context, compiler) { + rimrafSync(context.getDist()); + await new Promise(resolve => { + compiler.run(() => { + first_asset_mtime = fs.statSync( + path.join(context.getDist("main.js")) + )?.mtime; + setTimeout(() => { + compiler.run(() => { + resolve(); + }); + }, 100); + }); + }); + }, + async check(context) { + let second_asset_mtime = fs.statSync( + path.join(context.getDist("main.js")) + )?.mtime; + expect(first_asset_mtime).not.toEqual(second_asset_mtime); + } };