我在消费者端的 Pact JS 实现中遇到错误。当我尝试运行测试时,出现以下错误:
Pact stop failed; tried calling service 10 times with no result.
如果有任何帮助,请在下面附上我的代码片段:
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();
}
在测试本身:
afterEach(done => {
provider
.finalize()
.then(() => done())
.catch(err => catchAndContinue(err, done));
});
任何帮助将不胜感激。我是新手,不知道如何解决这个问题。
使用 pact: 4.2.1 和 @pact-foundation/pact-node: 6.0.0