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

标签 javascript node.js testing selenium-webdriver webdriver

我是 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- 开始测试(); 只是一些测试 WDIO

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

最佳答案

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

npm install forever 

及之后

forever start yourapp 

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

相关文章:

node.js - 不能在模块 Electron React Typescript 之外使用 import 语句

node.js - Node + ES6 类 : Setting up a set of cached objects

javascript - 选择除 sibling 和自身之外的所有元素

javascript - 这个 JavaScript 程序是如何工作的?

javascript - 数据表仅选择过滤的内容

javascript - jQuery 手机 : Multi-Page Application with Separate Pages: Second Page not Getting Styled

node.js - yarn 使用错误: how to use yarn on git bash

java - 没有 load() 方法我无法测试单例

java - onLowMemory 事件测试

c# - Web API 2 验证 Controller 正在生产环境中运行