If you use Angular CLI this library would be very helpful.
It will allow you to keep your workspace clear of boilerplate code related to Jest setup and also run your tests with Angular CLI (ng test).
This will also save you the trouble of configuring Jest.
As for your specific error, it is most probably related to your tsconfig.spec.json. Have you changed the module field to commonjs? This is required to make Jest work.
For more details read this article.
Disclaimer: I'm the owner of this library.
Answer from JeB on Stack OverflowVideos
If you use Angular CLI this library would be very helpful.
It will allow you to keep your workspace clear of boilerplate code related to Jest setup and also run your tests with Angular CLI (ng test).
This will also save you the trouble of configuring Jest.
As for your specific error, it is most probably related to your tsconfig.spec.json. Have you changed the module field to commonjs? This is required to make Jest work.
For more details read this article.
Disclaimer: I'm the owner of this library.
I tried a couple of weeks ago following this article.
It went smooth but I decided to not move from Jasmine/Karma to Jest. The reasons:
- I need to run UTs on multiple real browsers and Jest can't do it. (Read the discussion on the Jest Repository
- I can use Jasmin to write also e2e tests using Protractor or Selenium-Webdriver
» npm install jest-preset-angular
» npm install @angular-builders/jest