Created
June 14, 2022 15:33
-
-
Save solace/8f513ccd7757d3c4c7093f35ed546fcd to your computer and use it in GitHub Desktop.
StorybookJS: Include line entry in Interactions tab that appears in Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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