gpt4 book ai didi

javascript - 在执行其余测试时保持 nodeJs 服务器运行

转载 作者:行者123 更新时间:2023-11-29 21:04:48 26 4
gpt4 key购买 nike

我是 nodeJS 和 webdriveIO 的新手,正在编写一些 webdriveIO 测试,我有两个功能:短信服务器();和 startTest();

1- smsServer();

function smsServer(){
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
app.get('/',function(req,res){
console.log(req.query.text);
});
app.post('/', function(req,res){
console.log("Post");
console.log(req.body);
res.sendStatus(200);
});
app.listen(3000, function(req, res){
console.log('App listening on localhost:3000');
console.log("req: ",req);
console.log("res: ",res);
});
}

2- startTest();
只是一些测试 WDIO

我想让我的服务器保持运行以接收一些验证码,而在我的老板杀了我之前执行任何帮助的第二个功能(测试)将受到赞赏

最佳答案

在不终止进程或永远使用的情况下启动您的应用程序。但是,我认为当您为应用吃午餐时,服务器必须仍在运行,

npm install forever 

及之后

forever start yourapp 

关于javascript - 在执行其余测试时保持 nodeJs 服务器运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44543249/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com