[英]How do I run postman's newman in CI environment?
I'd like to run newman
on my CI environment (solano-ci).我想在我的 CI 环境 (solano-ci) 上运行
newman
。
newman
is a tool that runs through requests in your postman collection. newman
是一个工具,它运行您的邮递员集合中的请求。
I have a newman
script in my package.json
, and I also have a npm start
script that starts the server at localhost:3000
.我的
package.json
有一个newman
脚本,我还有一个npm start
脚本,它在localhost:3000
处启动服务器。
newman
is already configured with environment variables to test endpoints on port localhost:3000
. newman
已经配置了环境变量来测试端口localhost:3000
上的端点。
The issue is I need one script that starts the server ( npm start
) and then runs npm run newman
.问题是我需要一个脚本来启动服务器(
npm start
)然后运行npm run newman
。 But there's a delay between when the server is available and when newman
runs it's tests.但是在服务器可用和
newman
运行它的测试之间存在延迟。 If newman
runs before the server is available it results in an error for each test.如果
newman
在服务器可用之前运行,它会导致每次测试出错。
Error: connect ECONNREFUSED 127.0.0.1:3000
Right now here's what I tried using run-p
which works at starting two processes in parallel.现在这是我尝试使用
run-p
尝试并行启动两个进程的方法。 Then I have to use sleep
and set an arbitrary number of time the wait to ensure that the server is ready.然后我必须使用
sleep
并设置任意次数的等待以确保服务器准备就绪。
"newman": "newman -c ./postman/api.postman_collection.json -e ./postman/local.postman_environment.json",
"newman-sleep": "sleep 10 && npm run newman",
"newman-server": "run-p start newman-sleep"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.