From ad367be76e7ae2229a4cb007116d760e29989003 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 4 Feb 2022 01:22:32 +0800 Subject: [PATCH] Review comments --- README.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 70438fea..054a3c84 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Storybook test runner turns all of your stories into executable tests. - [Table of Contents](#table-of-contents) - [Features](#features) - [Getting started](#getting-started) + - [CLI Options](#cli-options) - [Configuration](#configuration) - [Running against a deployed Storybook](#running-against-a-deployed-storybook) - [Stories.json mode](#storiesjson-mode) @@ -100,16 +101,16 @@ yarn test-storybook Usage: test-storybook [options] ``` -| Options | Description | -| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `--help` | Output usage information
`test-storybook --help` | -| `-s`, `--stories-json` | Run in stories json mode (requires a compatible Storybook)
`test-storybook --stories-json` | -| `-c`, `--config-dir [dir-name]` | Directory where to load Storybook configurations from
`test-storybook -c .storybook` | -| `--watch` | Run in watch mode
`test-storybook --watch` | -| `--maxWorkers [amount]` | Specifies the maximum number of workers the worker-pool will spawn for running tests
`test-storybook --maxWorkers=2` | -| `--no-cache` | Disable the cache
`test-storybook --no-cache` | -| `--clearCache` | Deletes the Jest cache directory and then exits without running tests
`test-storybook --clearCache` | -| `--verbose` | Display individual test results with the test suite hierarchy
`test-storybook --verbose` | +| Options | Description | +| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| `--help` | Output usage information
`test-storybook --help` | +| `-s`, `--stories-json` | Run in stories json mode (requires a compatible Storybook)
`test-storybook --stories-json` | +| `-c`, `--config-dir [dir-name]` | Directory where to load Storybook configurations from
`test-storybook -c .storybook` | +| `--watch` | Run in watch mode
`test-storybook --watch` | +| `--maxWorkers [amount]` | Specifies the maximum number of workers the worker-pool will spawn for running tests
`test-storybook --maxWorkers=2` | +| `--no-cache` | Disable the cache
`test-storybook --no-cache` | +| `--clearCache` | Deletes the Jest cache directory and then exits without running tests
`test-storybook --clearCache` | +| `--verbose` | Display individual test results with the test suite hierarchy
`test-storybook --verbose` | ## Configuration @@ -255,6 +256,8 @@ To enable use cases like visual or DOM snapshots, the test runner exports test h The hooks, `preRender` and `postRender`, are functions that take a [Playwright Page](https://playwright.dev/docs/pages) and a context object with the current story `id`, `title`, and `name`. They are globally settable by `@storybook/test-runner`'s `setPreRender` and `setPostRender` APIs. +> **NOTE:** These test hooks are experimental and may be subject to breaking changes. We encourage you to test as much as possible within the story's play function. + To visualize the test lifecycle, consider a simplified version of the test code automatically generated for each story in your Storybook: ```js @@ -276,8 +279,6 @@ it('button--basic', async () => { }); ``` -> **NOTE:** These test hooks are experimental and may be subject to breaking changes. We encourage you to test as much as possible within the story's play function. - ### Image snapshot recipe If you want to make the test runner take image snapshots, the following recipe uses test hooks in `jest-setup.js` to do it: