diff --git a/web/.eslintrc.json b/web/.eslintrc.json index 2ca7ba73b..021e60c2e 100644 --- a/web/.eslintrc.json +++ b/web/.eslintrc.json @@ -1,8 +1,9 @@ { "env": { - "browser": true + "browser": true, + "jest": true }, "globals": { "process": true } } diff --git a/web/babel.config.cjs b/web/babel.config.cjs index c62ca93f2..8b78d1255 100644 --- a/web/babel.config.cjs +++ b/web/babel.config.cjs @@ -1,10 +1,24 @@ module.exports = { presets: ['@babel/preset-react', '@babel/preset-flow'], plugins: [ '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-object-rest-spread', '@babel/plugin-proposal-optional-chaining', '@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 index ccedea4be..e922a45ab 100644 --- a/web/package.json +++ b/web/package.json @@ -1,81 +1,95 @@ { "name": "web", "version": "0.0.1", "type": "module", "private": true, "license": "BSD-3-Clause", "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", "@babel/plugin-proposal-class-properties": "^7.13.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8", "@babel/plugin-proposal-object-rest-spread": "^7.13.8", "@babel/plugin-proposal-optional-chaining": "^7.13.12", "@babel/plugin-transform-react-constant-elements": "^7.13.13", "@babel/plugin-transform-runtime": "^7.13.10", "@babel/preset-env": "^7.13.12", "@babel/preset-flow": "^7.13.13", "@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", "concurrently": "^5.3.0", "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", "terser-webpack-plugin": "^2.1.2", "url-loader": "^2.2.0", "webpack": "^4.41.0", "webpack-cli": "^3.3.9", "webpack-dev-server": "^3.11.0" }, "dependencies": { "@babel/runtime": "^7.13.10", "@fortawesome/fontawesome-svg-core": "1.2.25", "@fortawesome/free-regular-svg-icons": "5.11.2", "@fortawesome/free-solid-svg-icons": "5.11.2", "@fortawesome/react-fontawesome": "0.1.5", "basscss": "8.0.2", "classnames": "^2.2.5", "core-js": "^3.6.5", "dateformat": "^3.0.3", "detect-browser": "^4.0.4", "exif-js": "^2.3.0", "history": "^4.6.3", "invariant": "^2.2.4", "is-svg": "^4.3.0", "isomorphic-fetch": "^3.0.0", "lib": "0.0.1", "lodash": "^4.17.21", "react": "17.0.2", "react-circular-progressbar": "^2.0.2", "react-color": "^2.13.0", "react-dnd": "^11.1.3", "react-dnd-html5-backend": "^11.1.3", "react-dom": "17.0.2", "react-feather": "^2.0.3", "react-hot-loader": "^4.12.14", "react-icomoon": "^2.4.1", "react-redux": "^7.1.1", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", "react-switch": "^5.0.1", "react-timeago": "^5.2.0", "redux": "^4.0.4", "redux-devtools-extension": "^2.13.2", "redux-thunk": "^2.2.0", "reselect": "^4.0.0", "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)" + ] } }