> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# blimmer/jest

This orb makes it easier to run jest tests in your CircleCI environment. A primary benefit is automatically restoring the jest cache for faster subsequent test runs. You must configure jest for caching to work (see https://github.com/blimmer/jest-circleci-orb#configuration)


## Commands

### configure

This command configures jest caching behaviors and must be run for jest/restore-cache and jest/save-cache to work properly.


### restore-cache

This command restores the jest-cache directory.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `jest-cache-location` | string | .jest-cache | The location of the jest cacheDirectory within the working directory |

### save-cache

This command saves the jest-cache directory.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `jest-cache-location` | string | .jest-cache | The location of the jest cacheDirectory within the working directory |

## Jobs

### test

Run jest tests, restoring jest's cache for speedier tests.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `checkout` | boolean | true | Boolean for whether or not to checkout as a first step. Default is true. |
| `executor` | executor | default | The executor to use |
| `jest-cache` | boolean | true | Boolean for whether or not to restore/save the jest cache. |
| `jest-cache-location` | string | .jest-cache | The location of the jest cacheDirectory within the working directory |
| `jest-command-override` | string |  | The command to use to run jest.
When package-manager is npm -> npx --no-install jest When package-manager is yarn or yarn-berry -> yarn jest
Optionally supply a custom command. For instance, if you're using a yarn monorepo, you could provide a `yarn workspaces foreach` command here.
 |
| `package-manager` | enum | npm | Select the default node package manager to use. NPM v5+ Required. |
| `package-manager-cache` | boolean | true | Cache your node packages automatically for faster install times. |
| `package-manager-install-command-override` | string |  | By default, packages will be installed with "npm ci", "yarn install --frozen-lockfile" or "yarn install --immutable".
Optionally supply a custom package installation command, with any additional flags needed.
 |
| `setup-steps` | steps |  | These steps are executed before all other steps. For example, you might log into a private NPM registry. |
| `test-result-path` | string |  | Path (absolute, or relative to your working_directory) to directory containing JUnit XML or Cucumber JSON test metadata files, or to a single test file. See https://circleci.com/docs/configuration-reference#storetestresults |

## Executors

### default

A default node docker image


| Parameter | Type | Default | Description |
|---|---|---|---|
| `tag` | string | lts | Pick a specific circleci/node image variant: https://hub.docker.com/r/cimg/node/tags
 |

## Examples

### test

Run jest tests

```yaml
version: '2.1'
orbs:
  jest: blimmer/jest@x.y.z
workflows:
  test:
    jobs:
      - jest/test
```

### test-use-yarn

Run jest tests

```yaml
version: '2.1'
orbs:
  jest: blimmer/jest@x.y.z
workflows:
  test:
    jobs:
      - jest/test:
          package-manager: yarn-berry
```

### test-with-private-npm-login

Run jest tests, logging into a private NPM registry

```yaml
version: '2.1'
orbs:
  jest: blimmer/jest@x.y.z
workflows:
  test:
    jobs:
      - jest/test:
          context:
            - npm
          setup-steps:
            - run:
                command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
                name: Login to NPM
```