没有可用的工作示例来演示 CucumberJS 与 TestCafe 的集成,显示 RestAPI 测试场景,有人可以建议一种方法吗?
No working example available to demonstrate CucumberJS integration with TestCafe showing RestAPI test scenario, can somebody suggest an approach?
我一直在探索 GitHub 上的项目,这些项目演示了将 TestCafe 与 CucumberJS 集成的功能,但是,我找不到任何参考来通过此集成测试 RestAPI,我需要它作为我的项目要求。
我可以请求某人 post 一个工作示例,目前我正在探索以下 repo:https://github.com/rquellh/testcafe-cucumber
我已经尝试探索 GitHub 上可用的项目:
https://github.com/search?p=3&q=testcafe+cucumber&type=Repositories
我期待基于 TestCafe 的 Cucumber BDD 驱动工作流:
https://devexpress.github.io/testcafe/documentation/test-api/intercepting-http-requests/
这里有两个选项。
如果您想通过从测试场景发送请求并检查响应来测试 RestAPI 本身,则不需要 TestCafe。根据 this issue TestCafe 仍然无法发出 HTTP 请求。此外,请求处理程序无法处理您使用外部工具从测试代码发出的请求。它们仅适用于测试页面发出的请求。
如果测试页面上的脚本发出 RestAPI 请求并且您想知道响应是什么,您可以像这样添加一个请求记录器:
let requestLogger = null;
Given('I use example.com REST API', async function () {
requestLogger = RequestLogger(/https:\/\/api\.example\.com/, {
logResponseHeaders: true,
logResponseBody: true
});
await testController.addRequestHooks(requestLogger);
});
然后您可以按照Test API documentation.
中所述从requestLogger
获取数据
我一直在探索 GitHub 上的项目,这些项目演示了将 TestCafe 与 CucumberJS 集成的功能,但是,我找不到任何参考来通过此集成测试 RestAPI,我需要它作为我的项目要求。
我可以请求某人 post 一个工作示例,目前我正在探索以下 repo:https://github.com/rquellh/testcafe-cucumber
我已经尝试探索 GitHub 上可用的项目:
https://github.com/search?p=3&q=testcafe+cucumber&type=Repositories
我期待基于 TestCafe 的 Cucumber BDD 驱动工作流:
https://devexpress.github.io/testcafe/documentation/test-api/intercepting-http-requests/
这里有两个选项。
如果您想通过从测试场景发送请求并检查响应来测试 RestAPI 本身,则不需要 TestCafe。根据 this issue TestCafe 仍然无法发出 HTTP 请求。此外,请求处理程序无法处理您使用外部工具从测试代码发出的请求。它们仅适用于测试页面发出的请求。
如果测试页面上的脚本发出 RestAPI 请求并且您想知道响应是什么,您可以像这样添加一个请求记录器:
let requestLogger = null;
Given('I use example.com REST API', async function () {
requestLogger = RequestLogger(/https:\/\/api\.example\.com/, {
logResponseHeaders: true,
logResponseBody: true
});
await testController.addRequestHooks(requestLogger);
});
然后您可以按照Test API documentation.
中所述从requestLogger
获取数据