我正在尝试将赛普拉斯与Angular(v.5)CLI应用程序一起使用.
在本地运行时测试工作正常,因为在这里我可以在运行cypress测试之前启动serve命令.
我尝试按照文档here,
但是这些命令似乎都没有起作用.
我尝试了varIoUes组合,看起来像这样:
"cypress:run:report": "./node_modules/.bin/cypress run --record --key <key>","cypress:run:ci": "start-server-and-test serve:dev http://localhost:4200 cypress:run:report","cypress:run:ci2": "npm run -s serve:dev & npm run -s cypress:run:report",
提前致谢.
解决方法
在尝试解决这个问题几个小时后,我使用
Cypress Module API开发了一个解决方案.
的package.json
"cypress:run:ci": "node ng-serve-and-run-cypress.js",
NG-发球和运行柏树
'use strict'; const cypress = require('cypress'); const { spawn } = require('child_process'); const child = spawn('ng',['serve']); // On error exit,and print child.on('error',(err) => process.exit(1)); child.stderr.on('data',(data) => console.log(data.toString())); // On exit,print exit code child.on('exit',(code,signal) => console.log(`Child exitting with code ${code}`)); child.stdout.on('data',(data) => { const asstring = data.toString(); // Log the output to inform CI/User console.log(asstring); if (asstring.includes('webpack: Compiled successfully.')) { cypress.run({}) .then((results) => { const errorCode = (results.failures >= 1) ? 1 : 0; child.kill(); // When cypress is done running the tests,exit with errorCode from above. process.exit(errorCode); }) .catch((err) => { child.kill(); // If cypress hit's an error,exit with code 1 process.exit(1); }) } });
如果您对更多细节感兴趣,请在此处发布.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。