I'm getting an error with the Pact JS implementation on the consumer side. When I'm trying to run my tests, I'm getting the following error:
Pact stop failed; tried calling service 10 times with no result.
Attaching snippets of my code below if that would be of any help:
import Pact from "pact";
import wrapper from "@pact-foundation/pact-node";
const mockEventsService = wrapper.createServer({
port: 1234,
spec: 2
});
let provider;
beforeEach(done => {
mockEventsService
.start()
.then(() => {
provider = Pact({
consumer: "Frontend",
provider: "Backend",
port: 1234
});
done();
})
.catch(err => catchAndContinue(err, done));
});
afterAll(() => {
wrapper.removeAllServers();
});
afterEach(done => {
mockEventsService
.delete()
.then(() => {
done();
})
.catch(err => catchAndContinue(err, done));
});
function catchAndContinue(err, done) {
fail(err);
done();
}
In the test itself:
afterEach(done => {
provider
.finalize()
.then(() => done())
.catch(err => catchAndContinue(err, done));
});
Any help would be greatly appreciated. I'm new to this and have no idea how to fix this.
Using pact: 4.2.1 and @pact-foundation/pact-node: 6.0.0