Skip to content

Commit

Permalink
Adding jest
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleemboyer committed Apr 13, 2021
1 parent 2a3c383 commit 7cca2ab
Show file tree
Hide file tree
Showing 6 changed files with 2,565 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["@babel/env", "@babel/preset-react"]
"presets": ["@babel/env", "@babel/preset-react", "@babel/preset-typescript"]
}
18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,34 @@
"build:dev": "webpack --mode development",
"build:prod": "webpack --mode production",
"dev": "webpack serve --mode development",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"keywords": [],
"author": "Ashlee M Boyer",
"license": "ISC",
"jest": {
"setupFilesAfterEnv": [
"./setupTests.ts"
],
"moduleNameMapper": {
"\\.(css|less)$": "identity-obj-proxy"
}
},
"devDependencies": {
"@babel/cli": "^7.1.0",
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.13.0",
"@types/enzyme": "^3.10.8",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/jest": "^26.0.22",
"babel-loader": "^8.0.2",
"css-loader": "^5.2.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"less": "^4.1.1",
"less-loader": "^8.1.0",
"style-loader": "^2.0.0",
Expand Down
6 changes: 6 additions & 0 deletions setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as Enzyme from 'enzyme';
const Adapter = require('enzyme-adapter-react-16');

Enzyme.configure({
adapter: new Adapter(),
});
10 changes: 10 additions & 0 deletions src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import Button from './Button';

describe('<Button />', () => {
it('has the correct className', () => {
const wrapper: ShallowWrapper = shallow(<Button />);
expect(wrapper.find('.Button')).toHaveLength(1);
});
});
5 changes: 4 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ module.exports = {
},
],
},
resolve: { extensions: ['*', '.js', '.jsx', '.ts', '.tsx'] },
resolve: {
extensions: ['*', '.js', '.jsx', '.ts', '.tsx'],
modules: 'node_modules',
},
output: {
path: path.resolve(__dirname, 'dist/'),
publicPath: '/dist/',
Expand Down
Loading

0 comments on commit 7cca2ab

Please sign in to comment.