DEV Community

Discussion on: Test Driven Development in an Angular World

Collapse
 
didirare profile image
didi-rare

Hi Catalin,

Great article you put up here, i am quite new to TDD and your article helped clarify somethings.

However in the farouriteMovieService test section there is the "jest" variable you used, and i was wondering how you got it. Is it from a library you added to the project?

Collapse
 
cthulhu profile image
Catalin Ciubotaru

Hello didi-rare!

Glad to hear that it’s helpful!
So, jest is an alternative to karma. It’s a test suite.
The variable comes from the “jest” package.
Let me knowing you need more info.

Collapse
 
didirare profile image
didi-rare

Hi,

Thanks for your reply, I figured Jest is a test suite when i did some research, i had installed and configured it following their guide, however the test fails when i run it. I get this error message "error TS2304: Cannot find name 'jest'."

I had installed the jest package, @types/jest, jest-preset-angular and added jest in types [] in all tsconfig.*.json files and i still get the same error.

Do you have any pointers?

I use Webstorm IDE.

Thread Thread
 
cthulhu profile image
Catalin Ciubotaru

So, all I have it this in my tsconfig.spec.json:

"types": ["jest", "node"]

Keep in mind they are not needed in all the others tsconfig.*.json files.

Also make sure you also install jest, not just jest-preset-angular.
So, you need jest, @types/jest and jest-preset-angular; then add the "jest" types to tsconfig.spec.json and that should be it.

Sorry for the late answer. Holiday more :)