it
Creates a custom story, allowing you to describe a stage of interaction with the UI and set test parameters.
tip
Also supported are other meta-attributes specific to a particular preview client.
retries
Defines the number of retry attempts in case of failure for an individual story. Accepts a device.
it('...', {
// Retry the test up to 3 times on failure. Only on mobile devices.
retries: (device) => (device.name === 'mobile' ? 3 : 0),
});
act
Describes actions performed in the story using an actor. This function emulates user actions such as button clicks, form submissions, and so on.
it('...', {
act: (actor) => actor.click(finder.getByText('Sign In')),
});
Accepts story environment as a second argument.
it('...', {
// The interface may differ on mobile devices
act: (actor, { device }) =>
device.name === 'mobile'
? // On phones, a swipe will be performed
actor.do(swipeProduct())
: // On desktop, a regular button click
actor.do(clickOnTrash()),
});
StoryAttributes
Public interface for external extensions of the test factory:
// Declare the interface in the @storyshots/core namespace
declare module '@storyshots/core' {
// TArg is a generic parameter, typically containing the structure of externals
interface StoryAttributes<TArg> {
// Any structures can be used, even functions.
prop: string;
}
}
// Configuration now supports the new property.
it('...', {
prop: 'property value',
});
tip
StoryAttributes combined with story functions enables implementing a wide range of useful behaviors.