add jest and enzyme testing dependencies and update infrastructure configuration to make testing work

This commit is contained in:
John Mitchell 2018-10-24 16:50:08 -04:00
parent 311346b77b
commit a76ac805f2
No known key found for this signature in database
GPG Key ID: FE6A9B5BD4EB5C94
5 changed files with 45 additions and 8 deletions

View File

@ -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"],

View File

@ -0,0 +1 @@
module.exports = 'svg-stub';

4
enzyme.config.js Normal file
View File

@ -0,0 +1,4 @@
const enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
enzyme.configure({ adapter: new Adapter() });

View File

@ -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$": "<rootDir>/__tests__/stubs/svgStub.js"
},
"setupTestFrameworkScriptFile": "<rootDir>/enzyme.config.js",
"testMatch": [
"<rootDir>/__tests__/tests/**/*.{js,jsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://127.0.0.1:3001",
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
]
},
"babel": {
"presets": [
"react-app"
]
}
}

View File

@ -1,4 +1,5 @@
const webpack = require('webpack');
const TARGET_PORT = 8043;
const TARGET = `https://localhost:${TARGET_PORT}`;