> For the complete documentation index, see [llms.txt](https://shoppinpal.gitbook.io/docs-shoppinpal-com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shoppinpal.gitbook.io/docs-shoppinpal-com/5.-the-frontend/unit-testing/karma-and-jasmin.md).

# Karma and Jasmin

## Configuring karma + jasmin for our angular app

### Introduction to tools

**Karma** is a test runner and it is a direct product from angularJS team. It provides flexibility to test your app in various browsers and is integrated with Jenkins, TravisCI and CircleCI continuous integration tools.

**Jasmin** is a test behavior driven development framework for testing javascript. It plays very well with karma. Similar to karma jasmin is also recommended as a framework of choice for AngularJS testing. Jasmin is dependency free.

### Practical fun

The repo for [AngularUnitTestDemo](https://github.com/Mohammed-Aadil/AngularUnitTestDemo) already has karma packages and its dependencies (karma-jasmine, jasmine-core, karma-chrome-launcher) so a simple npm command is sufficient to setup the project:

```bash
git clone https://github.com/Mohammed-Aadil/AngularUnitTestDemo
cd AngularUnitTestDemo
npm install
```

I have configured `package.json` to run `bower install` command on post install of npm packages. While npm is running, you can install karma command line tool in parallel, so open another terminal and run the following command:

```
npm install -g karma-cli
```

At this point we have installed `karma` and `jasmin` both. We are ready to create our karma configuration file so we can start writing tests. In a terminal, run the following command:

```
karma init
```

This command will ask you series of questions, just hit enter to accept defaults. At the end, it will generate a config file for karma: `karma.conf`. This file should look like:

```
module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine'],
    files: [
    ],
    exclude: [
    ],
    preprocessors: {
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    concurrency: Infinity
  })
}
```

**Note:** do not forget to update the `files` field in `karma.conf` file for angular and its dependencies.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://shoppinpal.gitbook.io/docs-shoppinpal-com/5.-the-frontend/unit-testing/karma-and-jasmin.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
