amiceli / vitest-cucumber

Use gherkin in your unit tests with vitest
https://vitest-cucumber.miceli.click
25 stars 2 forks source link

fix(before-after-hooks): await asynchronous before/after hooks #36

Closed chrisjarman closed 4 months ago

chrisjarman commented 4 months ago

The type definitions for [before|after][Each|All]Scenario suggest that asynchronous functions are supported (see use of MaybePromise), but the test runner doesn't actually await them.

This means asynchronous test setup/teardown doesn't work reliably.

This PR simply adds the necessary async/await tweaks to ensure that any asynchronous effect of async before/after hooks are actually completed, before each test run begins.

Again, apologies for another proposed patch without test coverage or reproduction steps 😅

I don't have very much time to work around my professional commitments, but I do want to help improve this library. @amiceli, if you're too busy to verify/validate this fix, please bear with me for a couple more days until I'm able to add proper test coverage.

amiceli commented 4 months ago

@chrisjarman Well done ;) for this PR. I finish my work day and I merge it.

It's not a problem if you don't have time to make unit tests, I will do it ;).

chrisjarman commented 4 months ago

Legend, thanks! I need tools like this because, obviously, I don't write enough tests ;)

amiceli commented 4 months ago

I finished my day ;). So I'm working to merge it. For scenario loops we don't need to await result. But with your PR I found someplace to use async and await ;) So thank you.

I will publish a new version when it's done.

amiceli commented 4 months ago

2.1.2 version is published ;)