0

I've set up a create-react-app with typescript, following the documentation on this page: https://create-react-app.dev/docs/adding-typescript/ and then following this page: https://jestjs.io/docs/getting-started

When I try to run the script: jest sum --notify I get the following error:

Error: Jest: Failed to parse the TypeScript config file /home/.../jest-playground/jest.config.ts
  Error: Jest: 'ts-node' is required for the TypeScript configuration files. Make sure it is installed
Error: Cannot find module 'ts-node'

But I have ts-node installed in my dependencies. package.json:

  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "@types/jest": "^26.0.15",
    "@types/node": "^12.0.0",
    "@types/react": "^17.0.0",
    "@types/react-dom": "^17.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "ts-jest": "^27.0.7",
    "ts-node": "^10.4.0",
    "typescript": "^4.1.2",
    "web-vitals": "^1.0.1"
  },

The app runs OK, but I can't get the testing to work?

1 Answer 1

1

it not have install test-jest and have't jest config

1, yarn add --dev ts-jest @types/jest
2, yarn ts-jest config:init
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.