<#1068 Provider testing - long-running `afterEach`...
# pact-js-development
g
#1068 Provider testing - long-running `afterEach` hook does not complete execution Issue created by james-kuihi Software versionsOS: Ubuntu 20 (via WSL2) • Consumer Pact library: Pact JS 10.4.1 • Provider Pact library: Pact JS 10.4.1 • Node Version: v18.12.1 Issue Checklist Please confirm the following: ☑︎ I have upgraded to the latest ☑︎ I have the read the FAQs in the Readme ☑︎ I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures ☑︎ I have set my log level to debug and attached a log file showing the complete request/response cycle ☑︎ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem Expected behaviour In the provider tests, when executing a long-running function in the
afterEach
hook, such as a database clean-up activity, then the function should complete execution before the test runner terminates. Actual behaviour Test runner terminates before the function completes execution. Steps to reproduce 1. Clone down the reproducing repository - https://github.com/james-kuihi/pact-js-aftreEach-bug-demo 2. Run the tests which reproduce the issue:
Copy code
cd examples/v3/afterEach-bug
npm install
npm test
You should see log output including:
Copy code
Starting afterEach
...
Finished afterEach
However, only the first line is present. The pertinent provider test which reproduces this is here. Relevant log files test.log Other This was raised and discussed on the PactJS Slack channel, and a improvement idea for the core framework raised in Canny. pact-foundation/pact-js