在空手道 UI 场景中拦截多个 graphql 操作总是 returns 来自模拟功能的第一个响应
Intercepting multiple graphql operations in a karate UI scenario always returns the first response from mock feature
我在顶部功能文件中的场景如下所示:
场景:获取猫类型id并创建猫
* driver.intercept({ patterns: [{ urlPattern: '*api/graphql*'}], mock:
'Mock.feature' })
When I click on the button to add a cat (//first graphql call happens. This gets cat types from the mock as expected)
And input a name
And select the cat type
And click create (//second graphql call happens here. But this returns the cat types again)
Then I see a success message
这里是mock.feature:
场景:karate.match("request contains operationName: 'getCatTypes'")
- def 响应 = 调用读取 ('response.json')
场景:karate.match("request contains operationName: 'AddCat'")
- def 响应 = 调用读取 ('response1.json')
我们使用空手道独立 jar 和版本 v1.2.0.RC1(也尝试使用 1.1.0)。
感谢任何 suggestions/directions。
你使用的karate.match()
是错误的,注意不是直接return一个boolean。阅读更多:
试试这个改变:
Scenario: karate.match("request contains operationName: 'getCatTypes'").pass
我也认为有更好的方法来完成上述操作,所以也请阅读:
我在顶部功能文件中的场景如下所示:
场景:获取猫类型id并创建猫
* driver.intercept({ patterns: [{ urlPattern: '*api/graphql*'}], mock:
'Mock.feature' })
When I click on the button to add a cat (//first graphql call happens. This gets cat types from the mock as expected)
And input a name
And select the cat type
And click create (//second graphql call happens here. But this returns the cat types again)
Then I see a success message
这里是mock.feature:
场景:karate.match("request contains operationName: 'getCatTypes'")
- def 响应 = 调用读取 ('response.json')
场景:karate.match("request contains operationName: 'AddCat'")
- def 响应 = 调用读取 ('response1.json')
我们使用空手道独立 jar 和版本 v1.2.0.RC1(也尝试使用 1.1.0)。
感谢任何 suggestions/directions。
你使用的karate.match()
是错误的,注意不是直接return一个boolean。阅读更多:
试试这个改变:
Scenario: karate.match("request contains operationName: 'getCatTypes'").pass
我也认为有更好的方法来完成上述操作,所以也请阅读: