From 943f8fabb5d4218e751b253220bce07599fed41d Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Fri, 26 Aug 2022 16:43:02 +0200 Subject: [PATCH] update Jest compatibility info --- README.md | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9ed3a24c..fdcf3694 100644 --- a/README.md +++ b/README.md @@ -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. -

Table of Contents

- [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) @@ -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 @@ -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