diff --git a/.babelrc b/.babelrc index 9c0f155..dae1e64 100644 --- a/.babelrc +++ b/.babelrc @@ -2,17 +2,5 @@ "presets": [ "env", "@babel/preset-react" - ], - "env": { - "test": { - "plugins": [ - "istanbul" - ] - }, - "production": { - "plugins": [ - "istanbul" - ] - } - } + ] } \ No newline at end of file diff --git a/.gitignore b/.gitignore index b46411f..5678280 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ package-lock.json src/api build dist +yarn.lock diff --git a/.travis.yml b/.travis.yml index e9eceb2..da421f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: node_js node_js: - node -script: npm run test +script: npm test diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..e35bc3f --- /dev/null +++ b/jest.config.js @@ -0,0 +1,6 @@ +module.exports = { + collectCoverage: true, + // Automatically clear mock calls and instances between every test + clearMocks: true, + testPathIgnorePatterns: ['/node_modules/', '/cypress/','build'] +}; \ No newline at end of file diff --git a/package.json b/package.json index c8a421c..321ecc6 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "dev": "nodemon --exec babel-node src/app.js ", + "test:watch": "jest --watchAll", "coverage": "nyc report --reporter=text-lcov | coveralls", "build": "webpack --mode production ", "heroku-postbuild": "npm run build", @@ -13,13 +14,11 @@ "precommit": "lint-staged", "test": "" }, - "lint-staged": { "*.{js,jsx}": [ - "git add" + "git add" ] - }, - + }, "nyc": { "require": [ "@babel/register" @@ -35,6 +34,8 @@ "author": "", "license": "ISC", "dependencies": { + "@testing-library/jest-dom": "^5.1.1", + "@testing-library/react": "^9.4.0", "apollo-boost": "^0.4.4", "babel-preset-env": "^2.0.0-alpha.20", "bcryptjs": "^2.4.3", @@ -42,6 +43,7 @@ "classnames": "^2.2.6", "express": "^4.16.3", "graphql": "^14.5.8", + "jest": "^25.1.0", "joi": "^14.0.1", "jsonwebtoken": "^8.3.0", "mongoose": "^5.3.6", @@ -52,6 +54,7 @@ "react-apollo": "^3.1.3", "react-router": "^5.0.1", "react-router-dom": "^5.0.1", + "react-test-renderer": "^16.12.0", "swagger-ui-express": "^4.0.1" }, "devDependencies": { diff --git a/src/client/components/Card/index.js b/src/client/components/Card/index.js index 762b931..89b60e6 100644 --- a/src/client/components/Card/index.js +++ b/src/client/components/Card/index.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; const Card = ({ featured_image, title, description, tags, ...rest }) => { return ( -