Migrate your Angular library to Jest

A step by step guide on how to migrate a multi-project Angular workspace to Jest

Kevin Kreuzer
Angular In Depth

--

AngularInDepth is moving away from Medium. More recent articles are hosted on the new platform inDepth.dev. Thanks for being part of indepth movement!

By default, the Angular CLI generates new Angular projects with Karma as a testing framework and Jasmine as an assertion library.

However, today, many people move away from this default stack and start to use Jest.

Jest is a testing framework created by Facebook, which continually gains steam. It’s super popular in the React world, and it now also starts to boom in the Angular world.

What are we going to learn 👨‍🎓

The Angular CLI sets up Karma with Jasmine. If you want to use Jest instead, you can either use the jest-schematics for normal SPAs or you need some manual setup, which is required for multi-project workspaces.

This blog post is a step by step guidance on how to generate or migrate an Angular library project (which is a multi-project workspace) to Jest.

☝ The Jest setup described in this blogpost works with Angular 8+, Jest 24+ and jest-preset-angular 8+.

--

--

Kevin Kreuzer
Angular In Depth

Passionate freelance frontend engineer. ❤️ Always eager to learn, share and expand knowledge.