storybookjs / test-runner

🚕 Turn stories into executable tests
https://storybook.js.org/docs/writing-tests/interaction-testing
MIT License
220 stars 66 forks source link

[feature request] Make tags available in the test context #446

Closed joakimgunst closed 2 months ago

joakimgunst commented 3 months ago

Tags can currently be used to include, exclude and skip specific stories in the test runner. It would be nice if the tags of the story were available on the TestContext which is passed as the second argument to e.g. postVisit. This would allow custom logic based on tags.

We currently have two use cases for this: skipping accessibility tests for the story (but not all tests), and delaying execution of the accessibility tests to not get a contrast violation when a component has a fade-in transition.

zb-sj commented 3 months ago

You can do this with getStoryContext which is actually described in the doc: Accessing story information with the test-runner

joakimgunst commented 2 months ago

Great, I didn't know that. Thank you @zb-sj!