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]: `defaultPrepare` should be exported #488

Open NotWoods opened 2 weeks ago

NotWoods commented 2 weeks ago

Is your feature request related to a problem? Please describe.

If I want to run some page setup with Playwright before page.goto, there's no good way to do so without rewriting everything the default prepare hook does.

Describe the solution you'd like

I'd like defaultPrepare to be exported or made available to the test runner config in some way, so I could write a config like:

export default {
  async prepare(args) {
    await args.page.addInitScript(...);
    await defaultPrepare(args);
  }
}

Describe alternatives you've considered

This could also be done as a prePrepare/postPrepare hook but then starts to balloon the config options available.

Are you able to assist to bring the feature to reality?

yes, I can

Additional context

No response