collection of frequently-used React hooks
"scripts": {
"test": "jest"
},
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
}
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
npm i @types/node typescript @types/jest ts-jest jest --save-dev
npm run build
npm i react
npm i --save-dev --legacy-peer-deps @testing-library/react-hooks
# Peer Dependencies
npm install react@^16.9.0
npm install --save-dev react-test-renderer@^16.9.0
Test environment jest-environment-jsdom cannot be found. Make sure the testEnvironment configuration option points to an existing node module.
npm i jest-environment-jsdom
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string. Consider using the "jsdom" test environment.
ReferenceError: document is not defined
fix by appending arguments test script in package.json
"scripts": {
"test": "jest --env=jsdom"
},