Getting Started with React 16 - #2 - Configuring Jest + Enzyme + TypeScript

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 6

  • @aparnaprasad1216
    @aparnaprasad1216 6 років тому +1

    I am trying to set up jest with typescript I am following your video. I get the following error when I run npm test:
    ClientApp\components\__tests__\index.spec.tsx
    ● Test suite failed to run
    TypeError: Cannot read property 'prototype' of undefined
    at module.exports (node_modules/request-promise-core/configure/request2.js:34:47)
    at Object. (node_modules/request-promise-native/lib/rp.js:15:1)
    at Object. (node_modules/jsdom/lib/api.js:6:17)
    Test Suites: 2 failed, 2 total
    Tests: 0 total
    Snapshots: 0 total
    Time: 0.661s
    Ran all test suites.
    npm ERR! Test failed. See above for more details.

    • @i-am-mateush
      @i-am-mateush  6 років тому

      Thank you for your comment!
      Could you remove the node_modules directory and package-lock.json file, and than try to run "npm install"? Did it work?
      I wrote an article on that, and you can find it here: medium.com/@mateuszsokola/configuring-react-16-jest-enzyme-typescript-7122e1a1e6e8

    • @aparnaprasad1216
      @aparnaprasad1216 6 років тому

      Thanks for the reply! I tried deleting node_modules and re installing again, but that did not work. I find that a particular package in package.json is causing it. The package is : "cn": "~0.1.1"
      Here is my package.json file:
      {
      "name": "my-app",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
      "react": "15.6.1",
      "react-dom": "15.6.1",
      "cn": "~0.1.1"
      },
      "scripts": {
      "start": "react-scripts-ts start",
      "eject": "react-scripts-ts eject",
      "test": "./node_modules/.bin/jest",
      "build": "./node_modules/.bin/webpack"
      },
      "devDependencies": {
      "@types/jest": "^22.2.3",
      "@types/react": "15.0.38",
      "@types/react-dom": "15.5.1",
      "jest": "^22.4.3",
      "typescript": "^2.8.1"
      },
      "jest": {
      "moduleFileExtensions": [
      "ts",
      "tsx",
      "js"
      ],
      "transform": {
      "^.+\\.(ts|tsx)$": "/test-preprocessor.js"
      },
      "testMatch": [
      "**/__tests__/*.(ts|tsx|js)"
      ]
      }
      }

    • @i-am-mateush
      @i-am-mateush  6 років тому

      Is your code available on Github?

  • @quatreiquorizawa9885
    @quatreiquorizawa9885 5 років тому +1

    OMG! Thank you!

    • @i-am-mateush
      @i-am-mateush  3 роки тому

      You are welcome. I uploaded a few new videos on React.