Skip to content

Commit

Permalink
#24 configure jest and enzyme
Browse files Browse the repository at this point in the history
  • Loading branch information
paleika committed Dec 29, 2020
1 parent 50a67e1 commit 79cfe0e
Show file tree
Hide file tree
Showing 5 changed files with 2,637 additions and 49 deletions.
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub'
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@
"scripts": {
"build": "webpack --config webpack.js --mode=production",
"start": "webpack-dev-server --hot --open --config webpack.js --mode=development",
"lint": "eslint src/"
"lint": "eslint src/",
"test": "jest --watch"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "^7.12.7",
"@babel/preset-react": "^7.12.7",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"clean-webpack-plugin": "^3.0.0",
"css-loader": "^5.0.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint": "^6.8.0",
"eslint-config-react-app": "^5.2.1",
"eslint-config-standard": "^14.1.1",
Expand All @@ -41,6 +45,8 @@
"file-loader": "^6.2.0",
"html-loader": "^1.3.2",
"html-webpack-plugin": "^4.5.0",
"jest": "^26.6.3",
"jest-enzyme": "^7.1.2",
"mini-css-extract-plugin": "^1.3.1",
"node-sass": "^5.0.0",
"optimize-css-assets-webpack-plugin": "^5.0.4",
Expand All @@ -50,5 +56,11 @@
"webpack": "^4.44.2",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.10.3"
},
"jest": {
"moduleNameMapper": {
"\\.(css|less|sass|scss)$": "<rootDir>/__mocks__/styleMock.js",
"\\.(gif|png|ttf|eot|svg)$": "<rootDir>/__mocks__/fileMock.js"
}
}
}
}
12 changes: 12 additions & 0 deletions src/components/app/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'
import Enzyme, { shallow } from 'enzyme'
import EnzymeAdapter from 'enzyme-adapter-react-16'

import App from './app'

Enzyme.configure({ adapter: new EnzymeAdapter() })

test('renders without error', () => {
const wrapper = shallow(<App />)
expect(wrapper).toBeTruthy()
})
Loading

0 comments on commit 79cfe0e

Please sign in to comment.