diff --git a/.eslintrc b/.eslintrc index 13453473b1..2131031f6b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,7 +9,7 @@ } }, "extends": [ - "airbnb", + "airbnb" ], "settings": { "react": { @@ -18,22 +18,24 @@ }, "env": { "browser": true, - "node": true + "node": true, + "jest": true }, "globals": { - "window": true, + "window": true }, "rules": { "camelcase": "off", "arrow-parens": "off", - "comma-dangle": "off", + "comma-dangle": "off", + "import/no-extraneous-dependencies": ["error", { "devDependencies": true }], "indent": ["error", 2, { "SwitchCase": 1 }], - "max-len": ['error', { + "max-len": ["error", { "code": 100, "ignoreStrings": true, - "ignoreTemplateLiterals": true, + "ignoreTemplateLiterals": true }], "no-continue": "off", "no-debugger": "off", @@ -42,7 +44,7 @@ "no-plusplus": "off", "no-underscore-dangle": "off", "no-use-before-define": "off", - "no-multiple-empty-lines": ["error", { max: 1 }], + "no-multiple-empty-lines": ["error", { "max": 1 }], "object-curly-newline": "off", "space-before-function-paren": ["error", "always"], "no-trailing-spaces": ["error"], diff --git a/__tests__/stubs/svgStub.js b/__tests__/stubs/svgStub.js new file mode 100644 index 0000000000..71adc36fed --- /dev/null +++ b/__tests__/stubs/svgStub.js @@ -0,0 +1 @@ +module.exports = 'svg-stub'; diff --git a/enzyme.config.js b/enzyme.config.js new file mode 100644 index 0000000000..bf9443b36a --- /dev/null +++ b/enzyme.config.js @@ -0,0 +1,4 @@ +const enzyme = require('enzyme'); +const Adapter = require('enzyme-adapter-react-16'); + +enzyme.configure({ adapter: new Adapter() }); diff --git a/package.json b/package.json index 7e8aba6089..16a437c618 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "start": "webpack-dev-server --config ./webpack.config.js --mode development", - "test": "echo \"No test specified\" && exit 0", + "test": "jest --watchAll", "lint": "./node_modules/eslint/bin/eslint.js src/**/*.js src/**/*.jsx" }, "keywords": [], @@ -14,16 +14,20 @@ "devDependencies": { "babel-core": "^6.26.3", "babel-eslint": "^10.0.0", + "babel-jest": "^23.6.0", "babel-loader": "^7.1.5", "babel-preset-react": "^6.24.1", "babel-preset-stage-2": "^6.24.1", "css-loader": "^1.0.0", + "enzyme": "^3.7.0", + "enzyme-adapter-react-16": "^1.6.0", "eslint": "^5.6.0", "eslint-config-airbnb": "^17.1.0", "eslint-plugin-import": "^2.14.0", "eslint-plugin-jsx-a11y": "^6.1.1", "eslint-plugin-react": "^7.11.1", "file-loader": "^2.0.0", + "jest": "^23.6.0", "node-sass": "^4.9.3", "react-hot-loader": "^4.3.3", "sass-loader": "^7.1.0", @@ -42,5 +46,30 @@ "react-redux": "^5.0.7", "react-router-dom": "^4.3.1", "redux": "^4.0.0" + }, + "jest": { + "collectCoverageFrom": [ + "src/**/*.{js,jsx}" + ], + "moduleNameMapper": { + "^[./a-zA-Z0-9$_-]+\\.svg$": "/__tests__/stubs/svgStub.js" + }, + "setupTestFrameworkScriptFile": "/enzyme.config.js", + "testMatch": [ + "/__tests__/tests/**/*.{js,jsx}" + ], + "testEnvironment": "jsdom", + "testURL": "http://127.0.0.1:3001", + "transform": { + "^.+\\.(js|jsx)$": "/node_modules/babel-jest" + }, + "transformIgnorePatterns": [ + "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$" + ] + }, + "babel": { + "presets": [ + "react-app" + ] } } diff --git a/webpack.config.js b/webpack.config.js index 1791d39837..85ec59d7bb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,5 @@ const webpack = require('webpack'); + const TARGET_PORT = 8043; const TARGET = `https://localhost:${TARGET_PORT}`;