Skip to content

Commit

Permalink
update Jest compatibility info
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Aug 26, 2022
1 parent 7f2ca3d commit 943f8fa
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions README.md
Expand Up @@ -2,16 +2,16 @@

Storybook test runner turns all of your stories into executable tests.

> ⚠️⚠️ If you're using **Jest 27** and can't migrate to Jest 28, please check the [Jest 27 support](#jest-27-support) section below.
<h2>Table of Contents</h2>

- [Features](#features)
- [How it works](#how-it-works)
- [Getting started](#getting-started)
- [Jest compatibility](#jest-compatibility)
- [CLI Options](#cli-options)
- [Configuration](#configuration)
- [Ejecting the configuration](#ejecting-the-configuration)
- [Jest-playwright options](#jest-playwright-options)
- [Jest options](#jest-options)
- [Test reporters](#test-reporters)
- [Running against a deployed Storybook](#running-against-a-deployed-storybook)
- [Index.json mode](#indexjson-mode)
Expand Down Expand Up @@ -104,16 +104,6 @@ yarn test-storybook
> TARGET_URL=http://localhost:9009 yarn test-storybook
> ```
### Jest compatibility

The Storybook test runner comes with Jest installed as an internal dependency. In case you are also using Jest as a dependency in your project, in order to avoid possible conflicts, you should use a compatible version of the test runner.

| Jest version | Test runner version |
| ------------ | ------------------- |
| ^26.6.3 | ^0.6.2 |
| ^27.0.0 | ^0.6.2 |
| ^28.0.0 | ^0.7.0 and higher |

## CLI Options

```plaintext
Expand Down Expand Up @@ -145,11 +135,26 @@ Usage: test-storybook [options]

The test runner is based on [Jest](https://jestjs.io/) and will accept most of the [CLI options](https://jestjs.io/docs/cli) that Jest does, like `--watch`, `--watchAll`, `--maxWorkers`, etc.

### Ejecting the configuration

The test runner works out of the box, but if you want better control over its configuration, you can run `test-storybook --eject` to create a local `test-runner-jest.config.js` file in the root folder of your project, which will be used by the test runner.

The test runner uses [jest-playwright](https://github.com/playwright-community/jest-playwright) and you can pass [testEnvironmentOptions](https://github.com/playwright-community/jest-playwright#configuration) to further configure it, such as how it's done above to run tests against all browsers instead of just chromium. For this you must eject the test runner configuration.
The configuration file will accept options for two runners:

#### Jest-playwright options

The test runner uses [jest-playwright](https://github.com/playwright-community/jest-playwright) and you can pass [testEnvironmentOptions](https://github.com/playwright-community/jest-playwright#configuration) to further configure it.

#### Jest options

The Storybook test runner comes with Jest installed as an internal dependency. You can pass Jest options based on the version of Jest that comes with the test runner.

| Test runner version | Jest version |
| ------------------- | ---------------------- |
| ^0.6.2 | ^26.6.3 or ^27.0.0 [1] |
| ^0.7.0 | ^28.0.0 |

> **NOTE:** The Jest options relate to the version of Jest that come in the test runner. You can check the [Jest compatibility table](#jest-compatibility) for reference.
[1]: if you have Jest installed in your project and install the test runner, if your Jest matches that version specifier, you will get the same version of the Jest in your project.

## Test reporters

Expand Down

0 comments on commit 943f8fa

Please sign in to comment.