Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set string to string[] when is not necessary in jest addon documentation #17009

Merged
merged 1 commit into from
Dec 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions addons/jest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You may want to add the result file to `.gitignore`, since it's a generated file

But much like lockfiles and snapshots, checking-in generated files can have certain advantages as well. It's up to you.
We recommend to **do** check in the test results file so starting Storybook from a clean git clone doesn't require running all tests first,
but this can mean you'll encounter merge conflicts on this file in the future (_re-generating this file is very similar to re-generating lockfiles and snapshots_).
but this can mean you'll encounter merge conflicts on this file in the future (_re-generating this file is very similar to re-generating lockfiles and snapshots_).

### Generating the test results

Expand Down Expand Up @@ -101,17 +101,17 @@ You can also add multiple tests results within your story by including the `jest
```js
// MyComponent.stories.js | MyComponent.stories.jsx

import MyComponent from './MyComponent';
import MyComponent from './MyComponent';

import results from '../.jest-test-results.json';
import results from '../.jest-test-results.json';

import { withTests } from '@storybook/addon-jest';
import { withTests } from '@storybook/addon-jest';

export default {
component: MyComponent,
title: 'MyComponent',
export default {
component: MyComponent,
title: 'MyComponent',
decorators: [withTests({ results })],
};
};

const Template = (args) => <MyComponent {....args} />;

Expand All @@ -126,7 +126,7 @@ Default.parameters = {

### Global level

To avoid importing the results of the tests in each story, you can update
To avoid importing the results of the tests in each story, you can update
your [`.storybook/preview.js`](https://storybook.js.org/docs/react/configure/overview#configure-story-rendering) and include a decorator allowing you to display the results only for the stories that have the `jest` parameter defined:

```js
Expand All @@ -140,7 +140,7 @@ export const decorators = [
withTests({
results,
}),
];
];
```

Then in your story file:
Expand All @@ -162,7 +162,7 @@ Default.args={
text: 'Jest results in Storybook',
};
Default.parameters = {
jest: ['MyComponent.test.js'],
jest: 'MyComponent.test.js',
};
```

Expand Down Expand Up @@ -230,7 +230,7 @@ const Template: Story<MyComponent> = (args: MyComponent) => ({

export const Default = Template.bind({});
Default.parameters = {
jest: ['MyComponent.component'],
jest: 'MyComponent.component',
};
```

Expand Down