-
-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provider testing - long-running afterEach
hook does not complete execution
#1068
Comments
I think this is the same bug as reported here: https://pact-foundation.slack.com/archives/C9VBGLUM9/p1677060601328999 |
Oh, you reported it the first time. Carry on! |
It seems to me that the If I add an export const registerAfterHook = (
app: express.Express,
config: ProxyOptions,
stateSetupPath: string
): void => {
app.use(async (req, res, next) => {
if (config.afterEach !== undefined) {
logger.trace("registered 'afterEach' hook");
next();
if (req.path !== stateSetupPath) {
logger.debug("executing 'afterEach' hook");
try {
await config.afterEach();
} catch (e) {
logger.error(`error executing 'afterEach' hook: ${e.message}`);
logger.debug(`Stack trace was: ${e.stack}`);
next(new Error(`error executing 'afterEach' hook: ${e.message}`));
}
}
} else {
next();
}
});
}; To my understanding it is not guaranteed that the response has completed at the point where Also note that if the In order to get the
|
Just picking up on this as we too have come across this behaviour of Log snippet:
This means we're unable to use |
Breaking change: Current behaviour will run the beforeEach and afterEach hooks multiple times if there are several provider states defined in an interaction. This change will ensure each of those hooks is run only once, regardless of how many provider states are defined in an interaction. Fixes pact-foundation#1068
Breaking change: Current behaviour will run the beforeEach and afterEach hooks multiple times if there are several provider states defined in an interaction. This change will ensure each of those hooks is run only once, regardless of how many provider states are defined in an interaction. Fixes pact-foundation#1068
Should be resolved by #1242 Feel free to comment back or raise a new issue if not sorted |
Breaking change: Current behaviour will run the beforeEach and afterEach hooks multiple times if there are several provider states defined in an interaction. This change will ensure each of those hooks is run only once, regardless of how many provider states are defined in an interaction. Fixes pact-foundation#1068
Current behaviour will run the beforeEach and afterEach hooks multiple times if there are several provider states defined in an interaction. This is due to the way the hook are run on every call to "/_pactSetup" via the proxy. This change will ensure each of those hooks is run only once per interaction, regardless of how many provider states are defined in that interaction. Fixes pact-foundation#1068
Current behaviour will run the beforeEach and afterEach hooks multiple times if there are several provider states defined in an interaction. This is due to the way the hook are run on every call to "/_pactSetup" via the proxy. This change will ensure each of those hooks is run only once per interaction, regardless of how many provider states are defined in that interaction. Fixes pact-foundation#1068
Software versions
Issue Checklist
Please confirm the following:
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
You should see log output including:
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.
The text was updated successfully, but these errors were encountered: