Cypress.io 使用 nodejs 包装时找不到规格



我正在尝试在 Cypress.io 之上添加一个REST API来模仿Appium框架。我可以从控制台运行测试,但是当我尝试使用 http 请求运行规范时,赛普拉斯找不到测试。我试图在位于项目根文件夹中的cypress.json中添加一堆不同的路径设置,但到目前为止还没有运气。

这是我想要实现的一个小示例服务器。

import express from 'express';
import cypress from 'cypress';
const app = express();
const PORT = 5000;
app.get('/cypress/v1/run/:specName', (req, res) => {
cypress.run({
spec: req.params.specName})
.then(results => {
res.status(200).send({
status: results.totalFailed,
result: results 
})
})
.catch((err) => {
console.error(err)
});
});
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`)
});

无论我发送什么,我都会收到以下错误:请求:
curl -v http://localhost:5000/cypress/v1/run/test.js
响应:{"result":{"failures":1,"message":"Could not find Cypress test run results"}}

日志:

Can't run because no spec files were found.
We searched for any files matching this glob pattern:
test.js

所以我的问题是,我错过了什么?

赛普拉斯似乎对配置非常敏感,有点不合逻辑。我将配置文件更改为以下内容,并找到了规格:

{
"projectId": "xyz123",
"integrationFolder": "cypress/integration",
"testFiles": "**/*.*"
}

我仍然必须将测试指定为cypress/integration/test.js,否则赛普拉斯将无法找到它。

最新更新