Skip to content

Commit

Permalink
Merge pull request #24600 from storybookjs/docs_updates_unit_tests
Browse files Browse the repository at this point in the history
Docs: Fix conditional rendering for Unit testing
  • Loading branch information
jonniebigodes authored Oct 27, 2023
2 parents e1bcbfe + 1a13287 commit 1b0ca54
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions docs/writing-tests/stories-in-unit-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,33 +172,44 @@ If you intend to test multiple stories in a single test, use the `composeStories

Storybook provides community-led addons for other frameworks like [Vue 2](https://storybook.js.org/addons/@storybook/testing-vue) and [Angular](https://storybook.js.org/addons/@storybook/testing-angular). However, these addons still lack support for the latest stable Storybook release. If you're interested in helping out, we recommend reaching out to the maintainers using the default communication channels (GitHub and [Discord server](https://discord.com/channels/486522875931656193/839297503446695956)).

### The args are not being passed to the test

<IfRenderer renderer='react'>

### The args are not being passed to the test

The components returned by `composeStories` or `composeStory` not only can be rendered as React components but also come with the combined properties from the story, meta, and global configuration. This means that if you want to access args or parameters, for instance, you can do so:

<!-- prettier-ignore-start -->

<CodeSnippets
paths={[
'react/reuse-args-test.js.mdx',
'react/reuse-args-test.ts.mdx',
]}
/>

<!-- prettier-ignore-end -->

</IfRenderer>

<IfRenderer renderer='vue'>

When using the `composeStories` or `composeStory` functions, the components being rendered will have a combination of properties from the story, meta, and global configuration. Therefore, if you need to access the args or parameters, you can do so as follows:
### The args are not being passed to the test

</IfRenderer>
When using the `composeStories` or `composeStory` functions, the components being rendered will have a combination of properties from the story, meta, and global configuration. Therefore, if you need to access the args or parameters, you can do so as follows:

<!-- prettier-ignore-start -->

<CodeSnippets
paths={[
'react/reuse-args-test.js.mdx',
'react/reuse-args-test.ts.mdx',
'vue/reuse-args-test.3.js.mdx',
'vue/reuse-args-test.3.ts.mdx',
]}
/>

<!-- prettier-ignore-end -->

</IfRenderer>

#### Learn about other UI tests

- [Test runner](./test-runner.md) to automate test execution
Expand Down

0 comments on commit 1b0ca54

Please sign in to comment.