🎉 This release contains work from a new contributor! 🎉
Thank you, Kasper Peulen (@kasperpeulen), for all your work!
Support 7.0.0 (#140)
Storybook 7.0.0 is out! This release will make @storybook/testing-react
compatible with Storybook 7, though I highly recommend not to use this package anymore!.
@storybook/testing-react
has been promoted to a first-class Storybook functionality in Storybook 7. This means that you no longer need this package. Instead, you can import the same utilities, but from the @storybook/react
package. Additionally, the internals of composeStories
and composeStory
have been revamped, so the way a story is composed is more accurate. The @storybook/testing-react
package will be deprecated, so we recommend you to migrate.
Please do the following:
- Uninstall this package
- Update your imports
- import { composeStories } from '@storybook/testing-react';
+ import { composeStories } from '@storybook/react';
// OR
- import { setProjectAnnotations } from '@storybook/testing-react';
+ import { setProjectAnnotations } from '@storybook/react';
Thank you so much for being with me on this journey! ✌️
Support Storybook 7.0 (#120)
This version adds support for Storybook 7.0. It requires you to be using Storybook 7.0, as there were several internal changes required, all of which depend on new Storybook packages.
In Storybook 7.0, the play function can also be defined in the Meta (default export). This is now supported in @storybook/testing-react
.
The setGlobalConfig
function is now deprecated in favor of setProjectAnnotations
, which aligns better with Storybook 7.0 nomenclature.
From:
import { setGlobalConfig } from '@storybook/testing-react';
import * as globalStorybookConfig from './.storybook/preview';
setGlobalConfig(globalStorybookConfig);
To:
import { setProjectAnnotations } from '@storybook/testing-react';
import * as globalStorybookConfig from './.storybook/preview';
setProjectAnnotations(globalStorybookConfig);
- Support Storybook 7.0 #120 (@IanVS @yannbf @kasperpeulen)
- Bump @storybook/csf to 0.1.0 #139 (@kasperpeulen)
- Support Storybook 7.0.0 #138 (@yannbf)
- Add test for handling csf3
name
->storyName
#108 (@IanVS)
- Ian VanSchooten (@IanVS)
- Kasper Peulen (@kasperpeulen)
- Michael Shilman (@shilman)
- Yann Braga (@yannbf)
🎉 This release contains work from new contributors! 🎉
Thanks for all your work!
❤️ Matt Harker (@TeaSeaLancs)
❤️ Alejandro Ñáñez Ortiz (@alejandronanez)
- feat: add React18 to peerDeps #100 (@alejandronanez)
- Allow render function to be sourced from story meta #103 (@TeaSeaLancs @yannbf)
- Alejandro Ñáñez Ortiz (@alejandronanez)
- Matt Harker (@TeaSeaLancs)
- Yann Braga (@yannbf)
- chore(deps): bump shelljs from 0.8.4 to 0.8.5 #82 (@dependabot[bot])
- update tests #92 (@yannbf)
- @dependabot[bot]
- Yann Braga (@yannbf)
🎉 This release contains work from new contributors! 🎉
Thanks for all your work!
❤️ Fabien (@frassinier)
❤️ Imgbot (@ImgBotApp)
❤️ Tatsushi Toji (@tatsushitoji)
- chore: update sb deps #79 (@frassinier)
- [ImgBot] Optimize images #53 (@ImgBotApp @imgbot[bot])
- Update linear-export.yml (@shilman)
- chore(docs): removed unnecessary "async" from sample code #74 (@tatsushitoji)
- @imgbot[bot]
- Fabien (@frassinier)
- Imgbot (@ImgBotApp)
- Michael Shilman (@shilman)
- Tatsushi Toji (@tatsushitoji)
- Yann Braga (@yannbf)
- chore(deps): bump url-parse from 1.5.1 to 1.5.3 in /example #72 (@dependabot[bot])
- chore(deps): bump path-parse from 1.0.6 to 1.0.7 in /example #71 (@dependabot[bot])
- chore(deps): bump tar from 6.1.0 to 6.1.11 in /example #68 (@dependabot[bot])
- chore(deps): bump ws from 5.2.2 to 5.2.3 in /example #67 (@dependabot[bot])
- chore(deps): bump tmpl from 1.0.4 to 1.0.5 in /example #66 (@dependabot[bot])
- @dependabot[bot]
- Yann Braga (@yannbf)
- Yann Braga (@yannbf)
feat: support exclude/include stories (#64)
This version adds support for the includeStories
and excludeStories
parameter to filter non-story exports (#64)
- Yann Braga (@yannbf)
🎉 This release contains work from new contributors! 🎉
Thanks for all your work!
❤️ Tom Coleman (@tmeasday)
❤️ null@jonniebigodes
Version 1.0.0 (#60)
Updates Storybook peer dependency to 6.4
Storybook 6.4 released a new version of CSF, where the story can also be an object. This is supported in @storybook/testing-react
, but you have to match the requisites:
1 - Either your story has a render
method or your meta contains a component
property:
// Example 1: Meta with component property
export default {
title: 'Button',
component: Button // <-- This is strictly necessary
}
// Example 2: Story with render method:
export const Primary = {
render: (args) => <Button {...args}>
}
Storybook 6.4 also brings a new function called play
, where you can write automated interactions to the story.
In @storybook/testing-react
, the play
function does not run automatically for you, but rather comes in the returned component, and you can execute it as you please.
Consider the following example:
export const InputFieldFilled: Story<InputFieldProps> = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await userEvent.type(canvas.getByRole('textbox'), 'Hello world!');
},
};
You can use the play function like this:
const { InputFieldFilled } = composeStories(stories);
test('renders with play function', async () => {
const { container } = render(<InputFieldFilled />);
// pass container as canvasElement and play an interaction that fills the input
await InputFieldFilled.play({ canvasElement: container });
const input = screen.getByRole('textbox') as HTMLInputElement;
expect(input.value).toEqual('Hello world!');
});
- Chore: (Docs) Updates the assets used in the documentation for the addon #52 (@jonniebigodes)
- @jonniebigodes
- Tom Coleman (@tmeasday)
- Yann Braga (@yannbf)
🎉 This release contains work from a new contributor! 🎉
Thank you, null@payapula, for all your work!
Revert CSF3 support (#43)
CSF3 support was added in a previous version, however conflicted with projects using Storybook 6.3. The correct typescript types come from Storybook 6.4, rendering this library incompatible with projects using Storybook 6.3.
This release reverts the CSF3 support, which will be brought to the next major release of @storybook/testing-react
.
- Revert CSF3 support #43 (@yannbf)
- chore: update auto configuration #45 (@yannbf)
- (docs) README - Corrected a small typo #39 (@payapula)
feat: support CSF3 format (#37)
Storybook released CSF3, where the story can also be an object. This is now supported in @storybook/testing-react. CSF3 also brings a new function called play
, where you can write automated interactions to the story.
In @storybook/testing-react, the play
does not run automatically for you, but rather comes in the returned component, and you can execute it as you please.
Consider the following example:
export const InputFieldFilled: Story<InputFieldProps> = {
play: async () => {
await userEvent.type(screen.getByRole('textbox'), 'Hello world!');
},
};
You can use the play function like this:
const { InputFieldFilled } = composeStories(stories);
test('renders with play function', async () => {
render(<InputFieldFilled />);
// play an interaction that fills the input
await InputFieldFilled.play!();
const input = screen.getByRole('textbox') as HTMLInputElement;
expect(input.value).toEqual('Hello world!');
});
- Yann Braga (@yannbf)
- Update TS information #33 (@eric-burel)
- json -> jsonc into tsconfig code block (@eric-burel)
- Eric Burel (@eric-burel)
- Ian VanSchooten (@IanVS)
- Yann Braga (@yannbf)
- Yann Braga (@yannbf)
- Luke Clark (@ljcl)
- Yann Braga (@yannbf)
- Yann Braga (@yannbf)
- fix: module field should point to a real file #21 (@elevatebart)
- Barthélémy Ledoux (@elevatebart)
- Yann Braga (@yannbf)
- Yann Braga (@yannbf)
- Yann Braga (@yannbf)
- Yann Braga (@yannbf)
- Fix: compose stories with partial props #9 (@yannbf)
- Update Button.stories.tsx #6 (@nativedone)
- AD Amorim (@nativedone)
- Yann Braga (@yannbf)
- Haz (@diegohaz)
- Yann Braga (@yannbf)
- Yann Braga (@yannbf)
- chore: add .env to gitignore (yannbf@gmail.com)
- fix(docs): use correct lib name in tsdoc (yannbf@gmail.com)
- chore(package): update project meta (yannbf@gmail.com)
- docs(README): add project description (yannbf@gmail.com)
- Yann Braga (@yannbf)
Initial version