> ## Documentation Index
> Fetch the complete documentation index at: https://trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Jasmine

> A guide for generating Trunk-compatible test reports for Jasmine tests

You can automatically [detect and manage flaky tests](../../detection/) in your Jasmine projects by integrating with Trunk. This document explains how to configure Jasmine to output JUnit XML reports that can be uploaded to Trunk for analysis.

## Setup steps

Work through the steps below in order. Once you've finished the last one, you'll be ready to move on to [configure uploads in CI](../ci-providers/).

<Steps>
  <Step title={<a href="#generating-reports">Generate a compatible test report</a>} />

  <Step title={<a href="#report-file-path">Configure the report file path or glob</a>} />

  <Step title={<a href="#disable-retries">Disable retries for better detection accuracy</a>} />

  <Step title={<a href="#try-it-locally">Test uploads locally</a>} />
</Steps>

## Generating Reports

Before integrating with Trunk, you need to generate Trunk-compatible reports. For Jasmine, the easiest approach is to generate XML reports.

First, install the [`jasmine-reporters`](https://www.npmjs.com/package/jasmine-reporters) package:

```shell theme={null}
npm install --save-dev jasmine-reporters
```

### In-Browser tests

When used for in-browser tests, the reporters are registered on a `jasmineReporters` object in the global scope (i.e. `window.jasmineReporters`). You can register it like this in your Jasmine config under `/spec/support/jasmine.mjs`:

```javascript title="/spec/support/jasmine.mjs" theme={null}
import jasmineReporters from 'jasmine-reporters';

var junitReporter = new jasmineReporters.JUnitXmlReporter({
    savePath: "test-reports",
    consolidateAll: false
});
jasmine.getEnv().addReporter(junitReporter);
```

### NodeJS

In Node.js, `jasmine-reporters` exports an object with all the reporters. You can register it like this in your Jasmine config under `/spec/support/jasmine.mjs`:

```javascript theme={null}
var reporters = require('jasmine-reporters');
var junitReporter = new reporters.JUnitXmlReporter({
    savePath: "test-reports",
    consolidateAll: false
});
jasmine.getEnv().addReporter(junitReporter)

```

### Report File Path

Jasmine will generate an XML report at the location specified by the `savePath` property. In the examples above, the XML report can be located with the glob `test-reports/*.xml`.

### Disable Retries

You need to disable automatic retries if you previously enabled them. Retries compromise the accurate detection of flaky tests.

If you're using a package like [protractor-flake](https://www.npmjs.com/package/protractor-flake), disable it to get more accurate results from Trunk. Instead, you can mitigate flaky tests using the [Quarantining](../../quarantining/) feature in Trunk.

## Try It Locally

### The Validate Command

You can validate your test reports using the [Trunk Analytics CLI](../../reference/cli-reference). If you don't have it installed already, you can install and run the `validate` command like this:

<CodeGroup>
  ```bash Linux (x64) theme={null}
  SKU="trunk-analytics-cli-x86_64-unknown-linux.tar.gz"
  curl -fL --retry 3 \
    "https://github.com/trunk-io/analytics-cli/releases/latest/download/${SKU}" \
    | tar -xz

  chmod +x trunk-analytics-cli
  ./trunk-analytics-cli validate --junit-paths "./test-reports/*.xml"
  ```

  ```bash Linux (arm64) theme={null}
  SKU="trunk-analytics-cli-aarch64-unknown-linux.tar.gz"
  curl -fL --retry 3 \
    "https://github.com/trunk-io/analytics-cli/releases/latest/download/${SKU}" \
    | tar -xz

  chmod +x trunk-analytics-cli
  ./trunk-analytics-cli validate --junit-paths "./test-reports/*.xml"
  ```

  ```bash macOS (arm64) theme={null}
  SKU="trunk-analytics-cli-aarch64-apple-darwin.tar.gz"
  curl -fL --retry 3 \
    "https://github.com/trunk-io/analytics-cli/releases/latest/download/${SKU}" \
    | tar -xz

  chmod +x trunk-analytics-cli
  ./trunk-analytics-cli validate --junit-paths "./test-reports/*.xml"
  ```

  ```bash macOS (x64) theme={null}
  SKU="trunk-analytics-cli-x86_64-apple-darwin.tar.gz"
  curl -fL --retry 3 \
    "https://github.com/trunk-io/analytics-cli/releases/latest/download/${SKU}" \
    | tar -xz

  chmod +x trunk-analytics-cli
  ./trunk-analytics-cli validate --junit-paths "./test-reports/*.xml"
  ```
</CodeGroup>

**This will not upload anything to Trunk**. To improve detection accuracy, you should **address all errors and warnings** before proceeding to the next steps.

### Test Upload

Before modifying your CI jobs to automatically upload test results to Trunk, try uploading a single test run manually.

You make an upload to Trunk using the following command:

```sh theme={null}
./trunk-analytics-cli upload --junit-paths "./test-reports/*.xml" \
    --org-url-slug <TRUNK_ORG_URL_SLUG> \
    --token <TRUNK_ORG_TOKEN>
```

You can find your Trunk organization slug and token in the settings or by following these [instructions](/flaky-tests/get-started/ci-providers/otherci#id-1.-store-a-trunk_token-secret-in-your-ci-system). After your upload, you can verify that Trunk has received and processed it successfully in the **Uploads** tab. Warnings will be displayed if the report has issues.

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/data-uploads-light.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=5da3bf1f0d49a59caa644ffc76e9ba9b" alt="" width="2560" height="1800" data-path="assets/_shared/data-uploads-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/data-uploads-dark.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=af72368eb5f745eebe1830b81bb6ea1a" alt="" width="2560" height="1800" data-path="assets/_shared/data-uploads-dark.png" />
</Frame>

## Next Steps

Configure your CI to upload test runs to Trunk. Find the guides for your CI framework below:

<Columns cols={3}>
  <Card title="Azure DevOps Pipelines" href="../ci-providers/azure-devops-pipelines" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/azure.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=3f5ce9354cd2034c2784530aaeb32e94" width="1600" height="1000" data-path="assets/_shared/azure.png" />

  <Card title="BitBucket Pipelines" href="../ci-providers/bitbucket-pipelines" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/bitbucket.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=5db5e364f1d46874cf68c62bdbcde6bf" width="1600" height="1000" data-path="assets/_shared/bitbucket.png" />

  <Card title="BuildKite" href="../ci-providers/buildkite" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/buildkite.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=29bc91156b4cba6707dbffbca8303129" width="1600" height="1000" data-path="assets/_shared/buildkite.png" />

  <Card title="CircleCI" href="../ci-providers/circleci" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/circle-ci.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=1117e1626eb77b293b73226c4a70946a" width="1600" height="1000" data-path="assets/_shared/circle-ci.png" />

  <Card title="Drone CI" href="../ci-providers/droneci" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/drone.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=a7f49c9235e78bfb1293a8754188eb0c" width="1600" height="1000" data-path="assets/_shared/drone.png" />

  <Card title="GitHub Actions" href="../ci-providers/github-actions" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/github.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=5638b5be83fcbd45ff2e731dc858e260" width="1600" height="1000" data-path="assets/_shared/github.png" />

  <Card title="GitLab" href="../ci-providers/gitlab" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/gitlab.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=178632b0348ff8060a392d06a89257b1" width="1600" height="1000" data-path="assets/_shared/gitlab.png" />

  <Card title="Jenkins" href="../ci-providers/jenkins" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/jenkins.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=d8133d18cd19a686241c5fe2c8784761" width="1600" height="1000" data-path="assets/_shared/jenkins.png" />

  <Card title="Semaphore" href="../ci-providers/semaphoreci" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/semaphore.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=8c31411e08e78b0670d40a04cbfc4691" width="1600" height="1000" data-path="assets/_shared/semaphore.png" />

  <Card title="TeamCity" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/teamcity.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=3bdb449b53d605a804e599213897fcbe" width="1600" height="1000" data-path="assets/_shared/teamcity.png" />

  <Card title="Travis CI" href="../ci-providers/travisci" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/travis.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=bd63e2d76333be604b7c887c9e1f77b1" width="1600" height="1000" data-path="assets/_shared/travis.png" />

  <Card title="Other CI Providers" href="../ci-providers/otherci" img="https://mintcdn.com/trunk-4cab4936-sam-gutentag-merge-queue-config-issues-panel/OcVIwrPAYH7tUya0/assets/_shared/other.png?fit=max&auto=format&n=OcVIwrPAYH7tUya0&q=85&s=a4f2320f2cae5b85b56e12e13de5ba1d" width="1600" height="1000" data-path="assets/_shared/other.png" />
</Columns>
