afterEach does not support async operation #1241
Labels
bug
Indicates an unexpected problem or unintended behavior
help wanted
Indicates that a maintainer wants help on an issue or pull request
triage
This issue is yet to be triaged by a maintainer
Software versions
Please provide at least OS and version of pact-js
Issue Checklist
Please confirm the following:
Expected behaviour
When defining an async function for
afterEach
, it should pause further execution of the verification tests until that Promise has resolved.We require async behaviour for clearing up state in
afterEach
as part of our verification tests.Actual behaviour
Test execution is not paused, and Promise is not handled cleanly.
Steps to reproduce
npm i -DE @pact-foundation/pact@latest
)provider.spec.js
to configure the provider verifier as so:./node_modules/.bin/jest provider.spec.js
)Given this
afterEach
hook, I would expect test execution to pause for ~2 seconds, but it doesn't and jest does not exit cleanly, giving the warning:Note the timestamps either side of the
executing 'afterEach' hook
log indicate execution on this thread is no paused ...Note that
beforeEach
does appear to support async operation. Here are the equivalent logs when replacingafterEach
withbeforeEach
in the above snippet, which show a ~2 second gap between logs:The text was updated successfully, but these errors were encountered: