diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 284627cc..69c8b134 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -67,7 +67,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x] + node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x] webpack-version: [latest] runs-on: ${{ matrix.os }} @@ -127,7 +127,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x] + node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x] runs-on: ${{ matrix.os }} diff --git a/test/TestCases.test.js b/test/TestCases.test.js index 2374a9c2..ed4a7c9b 100644 --- a/test/TestCases.test.js +++ b/test/TestCases.test.js @@ -23,7 +23,7 @@ function clearDirectory(dirPath) { for (let i = 0; i < files.length; i++) { const filePath = `${dirPath}/${files[i]}`; - if (fs.statSync(filePath).isFile()) { + if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) { fs.unlinkSync(filePath); } else { clearDirectory(filePath); @@ -31,7 +31,11 @@ function clearDirectory(dirPath) { } } - fs.rmdirSync(dirPath); + try { + fs.rmdirSync(dirPath); + } catch (_err) { + // Nothing + } } function compareDirectory(actual, expected) { diff --git a/test/emit-option.test.js b/test/emit-option.test.js index 1d46d924..18c5c9c4 100644 --- a/test/emit-option.test.js +++ b/test/emit-option.test.js @@ -315,42 +315,38 @@ describe("emit option", () => { await del([outputPath]); - const compiler1 = webpack(webpackConfig); + const compiler = webpack(webpackConfig); await new Promise((resolve, reject) => { - compiler1.run((error, stats) => { + compiler.run((error, stats) => { if (error) { reject(error); return; } - compiler1.close(() => { - expect(Object.keys(stats.compilation.assets).sort()).toMatchSnapshot( - `assets` - ); - expect( - Array.from(stats.compilation.emittedAssets).sort() - ).toMatchSnapshot(`emittedAssets`); - expect(getWarnings(stats)).toMatchSnapshot("warnings"); - expect(getErrors(stats)).toMatchSnapshot("errors"); + expect(Object.keys(stats.compilation.assets).sort()).toMatchSnapshot( + `assets` + ); + expect( + Array.from(stats.compilation.emittedAssets).sort() + ).toMatchSnapshot(`emittedAssets`); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); - resolve(); - }); + resolve(); }); }); - const compiler2 = webpack(webpackConfig); - await new Promise((resolve, reject) => { - compiler2.run((error, stats) => { + compiler.run((error, stats) => { if (error) { reject(error); return; } - compiler2.close(() => { + compiler.close(() => { expect(Object.keys(stats.compilation.assets).sort()).toMatchSnapshot( `assets` );