Fix Jest WASM tests

This commit is contained in:
Andras Schmelczer 2025-01-05 20:49:26 +00:00
commit 7e045caab1
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
4 changed files with 110 additions and 109 deletions

View file

@ -1,4 +1,4 @@
{ {
"jest.jestCommandLine": "npx jest", "jest.jestCommandLine": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest",
"jest.rootPath": "plugin" "jest.rootPath": "plugin"
} }

View file

@ -1,8 +1,3 @@
module.exports = { module.exports = {
testEnvironment: "node", preset: "ts-jest/presets/js-with-babel-esm"
moduleFileExtensions: ["js", "ts"],
testMatch: ["**/src/**/*.test.ts"],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
},
}; };

View file

@ -6,13 +6,12 @@
"scripts": { "scripts": {
"dev": "webpack watch --mode development", "dev": "webpack watch --mode development",
"build": "webpack --mode production", "build": "webpack --mode production",
"test": "jest", "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"lint": "eslint --fix src && prettier --write \"src/**/*.(ts|scss|json|html)\"", "lint": "eslint --fix src && prettier --write \"src/**/*.(ts|scss|json|html)\"",
"version": "node version-bump.mjs" "version": "node version-bump.mjs"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"type": "commonjs",
"license": "MIT", "license": "MIT",
"prettier": { "prettier": {
"trailingComma": "none", "trailingComma": "none",

View file

@ -27,6 +27,7 @@ module.exports = (env, argv) => ({
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: "styles.css" filename: "styles.css"
}), }),
new (require("webpack").DefinePlugin)({ new (require("webpack").DefinePlugin)({
__CURRENT_DATE__: Date.now() __CURRENT_DATE__: Date.now()
}), }),
@ -45,8 +46,14 @@ module.exports = (env, argv) => ({
]; ];
destinations.forEach((destination) => { destinations.forEach((destination) => {
fs.copy(source, destination) fs.copy(source, destination)
.then(() => console.log("Files copied successfully after build!")) .then(() =>
.catch((err) => console.error("Error copying files:", err)); console.log(
"Files copied successfully after build!"
)
)
.catch((err) =>
console.error("Error copying files:", err)
);
fs.createFile(path.join(destination, ".hotreload")); fs.createFile(path.join(destination, ".hotreload"));
}); });