diff --git a/web/.eslintrc.json b/web/.eslintrc.json --- a/web/.eslintrc.json +++ b/web/.eslintrc.json @@ -1,6 +1,7 @@ { "env": { - "browser": true + "browser": true, + "jest": true }, "globals": { "process": true diff --git a/web/babel.config.cjs b/web/babel.config.cjs --- a/web/babel.config.cjs +++ b/web/babel.config.cjs @@ -7,4 +7,18 @@ '@babel/plugin-proposal-nullish-coalescing-operator', ['@babel/plugin-transform-runtime', { useESModules: true }], ], + env: { + test: { + presets: [ + [ + '@babel/preset-env', + { + targets: { + node: 'current', + }, + }, + ], + ], + }, + }, }; diff --git a/web/package.json b/web/package.json --- a/web/package.json +++ b/web/package.json @@ -7,7 +7,8 @@ "scripts": { "clean": "rm -rf dist/ && rm -rf node_modules/", "dev": "yarn concurrently --names=\"NODESSR,BROWSER\" -c \"bgBlue.bold,bgMagenta.bold\" \"yarn webpack --config webpack.config.cjs --config-name=server --watch\" \"yarn webpack-dev-server --hot --config webpack.config.cjs --config-name=browser\"", - "prod": "yarn webpack --config webpack.config.cjs --env prod --progress" + "prod": "yarn webpack --config webpack.config.cjs --env prod --progress", + "test": "jest" }, "devDependencies": { "@babel/core": "^7.13.14", @@ -22,6 +23,7 @@ "@babel/preset-react": "^7.13.13", "@hot-loader/react-dom": "16.13.0", "assets-webpack-plugin": "^3.9.7", + "babel-jest": "^26.6.3", "babel-loader": "^8.1.0", "babel-plugin-transform-remove-console": "^6.9.4", "clean-webpack-plugin": "^3.0.0", @@ -29,6 +31,7 @@ "css-loader": "^4.3.0", "flow-bin": "^0.158.0", "flow-typed": "^3.2.1", + "jest": "^26.6.3", "mini-css-extract-plugin": "^0.11.2", "optimize-css-assets-webpack-plugin": "^5.0.3", "style-loader": "^1.2.1", @@ -77,5 +80,16 @@ "simple-markdown": "^0.7.2", "tinycolor2": "^1.4.1", "visibilityjs": "^2.0.2" + }, + "jest": { + "roots": [ + "/utils" + ], + "transform": { + "\\.js$": "babel-jest" + }, + "transformIgnorePatterns": [ + "/node_modules/(?!@babel/runtime)" + ] } }