mthuret / storybook-addon-specifications

:book: Write tests next to your stories and display their results inside storybook interface
458 stars 54 forks source link

Promise-based async interface #106

Open mikeapr4 opened 6 years ago

mikeapr4 commented 6 years ago

Code to resolve https://github.com/mthuret/storybook-addon-specifications/issues/105

For the moment the change only applies to it, though Jest/Mocha allows it on the before/after hooks too, so that might be some future work.

The check for a returned Promise matches what Mocha does: https://github.com/mochajs/mocha/blob/master/lib/runnable.js#L373

Nothing in this code actually requires the Promise class be available, means the code is compatible with pre-v0.12.18 node, although hardly a requirement to go back that far.

I've updated some tests, though more for illustrative purposes, as those tests will not fail if async doesn't work. I've updated the docs too so users know they can use both the done and Promise interfaces.

mikeapr4 commented 6 years ago

Can somebody take a look at this? @mthuret? @therealparmesh? I know this repo hasn't seen a lot of recent activity, but I think you'll find this PR is ready to merge.