@jony_starc/hooks

1.0.6 • Public • Published

@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"
  },

Readme

Keywords

none

Package Sidebar

Install

npm i @jony_starc/hooks

Weekly Downloads

1

Version

1.0.6

License

ISC

Unpacked Size

8.86 kB

Total Files

14

Last publish

Collaborators

  • jony_starc