ReferenceError: describe is not defined in Jest + Typescript

后端 未结 4 1810
灰色年华
灰色年华 2021-01-19 07:44

Simple configuration of Jest with ts-jest produces error \"ReferenceError: describe is not defined\" in runtime. Here minimal example: https://github.com/PFight/jest-ts-desc

相关标签:
4条回答
  • 2021-01-19 08:06

    I had the same problem but I needed the testEnvironment to be node. The solution is to downgrade to "jest": "^24.9.0". It seems like there's a problem with the latest version when testEnvironment is set to node.

    UPDATE

    It looks like this issue has been fixed in jest 25.2.2 per this comment https://github.com/facebook/jest/issues/9538#issuecomment-604522345 I haven't tested it though.

    0 讨论(0)
  • 2021-01-19 08:07

    I had same problem in node v10.14.1.

    Just update node to v10.16.2 and error was fixed.

    0 讨论(0)
  • 2021-01-19 08:18

    Found the problem. It was next row in jest.config.js:

    testEnvironment: 'node',
    

    Just removed it and error was fixed.

    0 讨论(0)
  • 2021-01-19 08:25

    Or you can add the type definitions for jest like this in your tsconfig: "include": ["node_modules/@types", "test/**/**.ts"],

    And add the types via installing it with npm -i @types/jest

    I can't push to your repo though creating a PR is not possible..

    0 讨论(0)
提交回复
热议问题