@jony_starc/hooks
v1.0.6
Published
create some frequently-used react hooks
Downloads
342
Readme
@jony_starc/hooks
collection of frequently-used React hooks
Run test case without errors
check script in package.json
"scripts": {
"test": "jest"
},
make sure options in tsconfig.json
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
}
make sure options in jest.config.json
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
command history
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
Issue 01:
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
Issue 02:
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"
},