Skip to content
This repository was archived by the owner on May 15, 2022. It is now read-only.

Commit 69c1e3e

Browse files
committed
Implement Jest, @testing-library and basic test
1 parent 6cbc67c commit 69c1e3e

File tree

4 files changed

+2379
-47
lines changed

4 files changed

+2379
-47
lines changed

jest.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Configure Jest as the test runner for @testing-library
3+
*
4+
* @see https://jestjs.io/docs/en/configuration
5+
*/
6+
module.exports = {
7+
setupFilesAfterEnv: [
8+
'@testing-library/jest-dom/extend-expect',
9+
'babel-polyfill'
10+
],
11+
collectCoverage: true,
12+
coveragePathIgnorePatterns: ['/node_modules/', '/__tests__/'],
13+
testMatch: ['**/__tests__/**/*.(spec|test).[jt]s?(x)']
14+
};

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"build": "rollup -c",
3636
"start": "rollup -c -w",
3737
"prepare": "yarn run build",
38+
"test": "jest",
39+
"test:watch": "jest --watch",
3840
"dev": "npm run start --prefix dev",
3941
"lint-js": "eslint --ignore-path .gitignore --ignore-pattern \"!**/.*\" .",
4042
"fix-js": "yarn run lint-js --fix"
@@ -74,8 +76,11 @@
7476
"@babel/plugin-transform-runtime": "^7.5.0",
7577
"@babel/preset-env": "^7.5.4",
7678
"@babel/preset-react": "^7.0.0",
79+
"@testing-library/jest-dom": "^4.1.0",
80+
"@testing-library/react": "^9.1.3",
7781
"babel-eslint": "10.0.2",
7882
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
83+
"babel-polyfill": "^6.26.0",
7984
"eslint": "^6.2.0",
8085
"eslint-config-airbnb": "^18.0.1",
8186
"eslint-config-prettier": "^6.1.0",
@@ -85,6 +90,7 @@
8590
"eslint-plugin-react": "^7.14.2",
8691
"eslint-plugin-react-hooks": "^1.7.0",
8792
"husky": "^3.0.4",
93+
"jest": "^24.9.0",
8894
"lint-staged": "^9.2.3",
8995
"prettier": "^1.18.2",
9096
"prop-types": "^15.7.2",

src/__tests__/DatGUI.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import DatGUI from '../../dist/index.cjs';
4+
5+
test('Renders without errors', () => {
6+
render(<DatGUI data={{ data: {} }} onUpdate={() => null} />);
7+
});

0 commit comments

Comments
 (0)