# Jest

<div align="center" data-full-width="false"><figure><img src="https://1326643208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnpMhTPhBTwVaw7bZVBjY%2Fuploads%2Fvtma3oEr5WnCiCy9SJxS%2Fjest-js-icon.svg?alt=media&#x26;token=2af42ea9-76c6-4785-b1c1-ba7554717f7c" alt="" width="299"><figcaption></figcaption></figure></div>

Jest is a delightful JavaScript Testing Framework with a focus on simplicity.It works with projects using: [Babel](https://babeljs.io/), [TypeScript](https://www.typescriptlang.org/), [Node](https://nodejs.org/), [React](https://reactjs.org/), [Angular](https://angular.io/), [Vue](https://vuejs.org/) and more! Jest can generate standard format JUnit-style XML files which can be submited to Testfiesta or Testrail using Tacotruck CLI. You just need to install the popular [`jest-junit`](https://www.npmjs.com/package/jest-junit) package and install tacotruck cli or use [Github action](https://github.com/testfiesta/tacotruck-action). Check out simple jest [example](https://github.com/testfiesta/tacotruck-examples/tree/main/demo-jest-tf).

### Configuration

To generate xml report file output,  folder and file name should be configured in config file

```javascript
//jest.config.js

/** @type {import('jest').Config} */
const config = {
  reporters: [
    'default',
    ['jest-junit', {outputDirectory: 'reports', outputName: 'test-results.xml'}],
  ],
};

module.exports = config;
```

### Install Tacotruck CLI

{% code overflow="wrap" fullWidth="false" %}

```sh
$ npm install -g @testfiesta/tacotruck
```

{% endcode %}

### Submit test results

{% tabs %}
{% tab title="Testfiesta" %}

```sh
tacotruck testfiesta \
  run:submit \
  --token testfiesta_... \
  --handle orgHandle \
  --project projectKey \
  --name runName \
  --data results-path/*.xml
```

{% endtab %}
{% endtabs %}

### Github Action

{% tabs %}
{% tab title="Testfiesta" %}

```yaml
name: jest
on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./demo-jest-tf
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - name: 📦 Install dependencies
        run: npm install
      - name: 🧪 Test
        run: npm run test
      - name: Report Results
        if: false
        uses: testfiesta/tacotruck-action@v1
        with:
         provider: testfiesta
         handle: handle
         project: project
         base-url: https://staging.api.testfiesta.com
         credentials: ${{ secrets.TESTFIESTA_API_KEY }}
         run-name: Jest CI run ${{ github.run_number }}
         results-path: ./demo-jest-tf/reports/test-results.xml
```

{% endtab %}
{% endtabs %}

### Support and Resources

* [TacoTruck Examples](https://github.com/testfiesta/tacotruck-examples)
* [Jest Docs](https://jestjs.io/docs/getting-started)
* [Tacotruck Issues](https://github.com/testfiesta/tacotruck/issues)
* [**CLI Reference**](https://docs.testfiesta.com/automation/tacotruck-cli)
* [Tacotruck Github Action](https://github.com/testfiesta/tacotruck-action)
