Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3 add jest and testing library #18

Merged
merged 12 commits into from
Jan 31, 2023
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"env": {
"browser": true,
"es6": true,
"node": true
"node": true,
"jest": true
},
"extends": ["eslint:recommended", "prettier"],
"globals": {
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
node_modules
package-lock.json
coverage
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Dependency directories
node_modules/
coverage

dist
7 changes: 7 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript',
],
};
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
testEnvironment: 'jsdom',
moduleNameMapper: {
'.(css|less|scss)$': 'identity-obj-proxy',
},
};
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"build-storybook": "build-storybook",
"lint": "eslint",
"lint:fix": "eslint --fix",
"prettier": "prettier --write ."
"prettier": "prettier --write .",
"test": "jest",
"test:coverage": "jest -i --coverage",
"test:watch": "jest -i --watchAll"
},
"repository": {
"type": "git",
Expand All @@ -22,6 +25,9 @@
"homepage": "https://github.com/iurynogueira/ion-react#readme",
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.0",
Expand All @@ -35,15 +41,21 @@
"@storybook/preset-scss": "^1.0.3",
"@storybook/react": "^6.5.16",
"@storybook/testing-library": "^0.0.13",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.4.0",
"@types/react": "^18.0.27",
"babel-loader": "^8.3.0",
"css-loader": "^6.7.3",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"babel-jest": "^29.4.1",
"babel-loader": "^8.3.0",
"css-loader": "^6.7.3",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"prettier": "^2.8.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
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 React from 'react';
import { render } from '@testing-library/react';

import Button from './button';

describe('Button', () => {
test('renders the Button component', () => {
render(<Button label="Hello world!" />);
});
});
Loading