(original) (raw)

Migrating from Jasmine to Jest

January 01, 2024 - entry level, jest, testing; 1 minute reading time

If you want to migrate Jasmine tests to Jest, jest-codemods helps you a lot. I used it in a project with more than 200 tests, and it slashed the effort by several days:

npx jest-codemods

The tool is going to ask you a few questions. Here are the correct answers for a standard Angular project:

? Which parser do you want to use? ! TypeScript ? Which test library would you like to migrate from? ! Jasmine: globals ? Are you using the global object for assertions (i.e., without requiring them)? ! Yes, and I'm not afraid of false positive transformations ? Will you be using Jest on Node.js as your test runner? ! Yes, use the globals provided by Jest (recommended)

The tool doesn't fix every incompatiblity. Luckily, most issues are pretty obvious. Richard Wotzlaw has written a deep dive on migrating to Jest, including list of replacements.

How to set up Jest for an Angular 17 monorepo manually

January 01, 2024 - entry level, jest, testing, angular; 7 minutes reading time

The nice thing about Jest is it's easy to get started. However, most tutorials tell you about setting up Jest in a default Angular project. I was interested in using Jest in a monorepo, so I had to research.

As far as I can see, there are five roads you can go:

more...