当我运行我的running测试时,我会得到以下错误--“在调用called时,Pact模拟服务没有运行”。
我正在运行测试的项目在GitHub - https://github.com/pactflow/example-consumer/tree/master/src中。
我使用这个命令- npm运行测试。
请参阅下面我的详细内容-
调用验证时,pact模拟服务没有运行
12 | describe('API Pact test', () => {
13 | beforeAll(() => mockProvider.setup());
> 14 | afterEach(() => mockProvider.verify());
| ^
15 | afterAll(() => mockProvider.finalize());
16 |
17 | describe('retrieving a product', () => {
at Pact.verify (node_modules/@pact-foundation/src/httpPact.ts:136:9)
at Object.<anonymous> (src/api.pact.spec.js:14:32)发布于 2022-04-04 21:18:14
问题是通往我的项目的道路太长了。我读到契约只允许80个字符的路径长度。
发布于 2022-04-05 19:01:08
我也收到了同样的错误:The pact mock service wasn't running when verify was called,但是查看调试日志似乎是在抛出
thrown: "Exceeded timeout of 5000 ms for a hook.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."为了解决这个问题,我添加了下面的代码,就像早青这里建议的那样。
// jest.config.js
module.exports = {
// ...
testTimeout: 20000
}似乎与第27版的jest有关,因为另一个项目26正在正常工作。
https://stackoverflow.com/questions/71728146
复制相似问题