03.2 getting started karma - ranhs/soda-test GitHub Wiki

When starting a new Angular application, the Angular CLI sets up everything you need to unit testing using Karama and Jasmine.
If you are using Angular15 or above you might want the create the karma.config.js (in earlier versions of Angular it is created automatically). To create this file run the command ng generate config karma before setting the soda-test settings
Even though Angular CLI sets the test environment, in order to be able to use all the features in soda-test you need to make a small adjustment in the configuration file.

Installation

In order to write unit tests using soda-test you need to install it using the command:

npm install soda-test --save-dev

Set Angular-Test to use Karma though soda-test

In the angular.json file find the test builder definition of your angular project:

{
   ...
   "projects": {
      "my-app": {
         ...
         "architect": {
            ...
            "test": {
               "builder": "@angular-devkit/build-angular:karma",
               ...
            },
            ...
         }
      }
   },
   "defaultProject": "my-app"
}

Replace the follwing line:

"builder": "@angular-devkit/build-angular:karma",

With the follwoing line:

"builder": "soda-test:karma",

For more information about getting started with soda-test see the general Getting started page
⚠️ **GitHub.com Fallback** ⚠️