Skip to content

Commit

Permalink
fix test cases for node 17
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Oct 29, 2021
1 parent 1d7f6da commit c2b6f78
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion test/WasmHashes.unittest.js
Expand Up @@ -15,7 +15,10 @@ const wasmHashes = {
const createMd4Hash = require("../lib/util/hash/md4");
return {
createHash: createMd4Hash,
createReferenceHash: async () => createHash("md4"),
createReferenceHash:
parseInt(process.version.slice(1), 10) < 17
? async () => createHash("md4")
: createMd4Hash,
regExp: /^[0-9a-f]{32}$/
};
}
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/StatsTestCases.basictest.js.snap
Expand Up @@ -952,9 +952,9 @@ webpack x.x.x compiled successfully in X ms"

exports[`StatsTestCases should print correct stats for exclude-with-loader 1`] = `
"hidden assets 34 bytes 1 asset
asset bundle.js 5.28 KiB [emitted] (name: main)
asset bundle.js 5.25 KiB [emitted] (name: main)
runtime modules 1.72 KiB 5 modules
hidden modules 123 bytes 2 modules
hidden modules 99 bytes 2 modules
cacheable modules 119 bytes
./index.js 77 bytes [built] [code generated]
./a.txt 42 bytes [built] [code generated]
Expand Down
3 changes: 3 additions & 0 deletions test/statsCases/exclude-with-loader/webpack.config.js
Expand Up @@ -18,6 +18,9 @@ module.exports = {
{
test: /\.json/,
loader: "file-loader",
options: {
name: "[sha256:hash:8].[ext]"
},
type: "javascript/auto"
}
]
Expand Down
5 changes: 2 additions & 3 deletions test/statsCases/real-content-hash/test.config.js
@@ -1,6 +1,6 @@
const fs = require("fs");
const path = require("path");
const crypto = require("crypto");
const createHash = require("../../../lib/util/createHash");

const hashedFiles = {
"file.jpg": a => a.name.endsWith(".jpg"),
Expand Down Expand Up @@ -31,8 +31,7 @@ module.exports = {
const asset = statsData.assets.find(hashedFiles[name]);
expect(asset).not.toBe(undefined);
const content = fs.readFileSync(path.resolve(__dirname, "a", name));
const hash = crypto
.createHash("md4")
const hash = createHash("md4")
.update(content)
.digest("hex")
.slice(0, 20);
Expand Down

0 comments on commit c2b6f78

Please sign in to comment.