Skip to content

Instantly share code, notes, and snippets.

@solace
Created June 14, 2022 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solace/8f513ccd7757d3c4c7093f35ed546fcd to your computer and use it in GitHub Desktop.
Save solace/8f513ccd7757d3c4c7093f35ed546fcd to your computer and use it in GitHub Desktop.
StorybookJS: Include line entry in Interactions tab that appears in Actions
// Don't do this. This is awful.
// Documenting it because it works, but stinks to hell.
Blah.play = async () => {
const actionListener = jest.fn();
// Listen for events that log to the Actions tab.
const channel = addons.getChannel();
channel.addListener("storybook/actions/action-event", actionListener);
// Inspect that what you're looking for is about to be logged.
await expect(actionListener).toHaveBeenCalledWith(
{ blah: true }
);
// Remove the listener.
channel.removeListener("storybook/actions/action-event", actionListener);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment