Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferenceError: describe is not defined in Jest + Typescript

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-describe-not-defined-problem

What I configured wrong?

like image 379
Pavel Avatar asked Jan 27 '20 08:01

Pavel


3 Answers

I had same problem in node v10.14.1.

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

like image 58
ocknamo-bb Avatar answered Oct 19 '22 11:10

ocknamo-bb


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

testEnvironment: 'node',

Just removed it and error was fixed.

like image 35
Pavel Avatar answered Oct 19 '22 09:10

Pavel


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.

like image 5
GreatPyrenees Avatar answered Oct 19 '22 10:10

GreatPyrenees