test-runner
test-runner copied to clipboard
[Feature Request] `teardown` test hook API
Describe the feature request
Storybook Test Runner test hook api has a setup, preRender, and postRender but no teardown.
Why does this matter?
We trying to connect to an on-prem (for security concerns) visual differential tool but the lacking of a teardown function means we can't send a proper request to finalize the batch. When an engineer gets a visual regression instead of reviewing/approving a single batch of all the components, she has to go through 80 "batches", one for each component because we're sending the call to finalize the batch after the postRender call.
I'm happy to submit a PR for this. Any thoughts on what would be the best way to add a teardown hook? I've tried adding it to playwright/jest-setup.js but I can't seem to find a way to trigger the function when Jest runs it's teardown.
Hey @puppybits! Feel free to open a PR and we can do experimentations to get it over the finish line. These are possible places to take a look at: https://github.com/storybookjs/test-runner/blob/future/playwright/custom-environment.js#L13 https://github.com/storybookjs/test-runner/blob/future/playwright/global-teardown.js#L6
Adding another use case from #109:
It would be very useful to have teardown() hook similar to setup() so we can run code after all stories are tested.
One use-case is to write github test summary after tests finish. Which would be super useful for a11y tests.
But in principle there can be many things that afterAll or teardown function would be useful.