我正在测试负载测试。 我还使用faker
使用request包我想检查注册
注册的fronend网址是
本地主机/测试/ signup.com 并转到 localhost:8081 / register 像这样
$.ajax({ type: "POST", url: commonpath+'register', dataType: "JSON", data: {first_name:firstname,last_name:lastname, user_name:username,email:eamilid,password:password}, async: true, success: function(data) {
依旧......
我创建了一个用于测试的新文件
这是代码
exports.fakedata = function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
for (var i=0; i < number_of_signups; i++) {
identities.push({
first_name: faker.name.firstName(),
last_name: faker.name.lastName(),
user_name : "hitu"+faker.internet.email(),
email: "hitu"+faker.internet.email(),
password: faker.internet.password()
});
}
async.each(identities, submit, function(err,res) {
console.log("each function");
if(err) throw err;
console.log('done...');
process.exit();
});
//console.log(JSON.stringify(identities));
};
function submit(identity, callback) {
console.log(JSON.stringify(identity));
firstname="hello"; / jsut tio chck */
lastname= "hhf";//identity[0].last_name;
username= "dffflffl";//identity.user_name;
email="email@hitemai.com"//identity.email;
password= "dddd";//identity.password;
var opts = {
url: 'http://localhost:8081/register',
method: 'POST',
data: {first_name:firstname,last_name:lastname, user_name:username,email:email,password:password},
};
request(opts, function(err, connection, body) {
if(err) {
console.log("there is an error " +err);
return callback(err);
}else {
console.log("pls check db entry ");
callback();
}
});
}
在我正在检查消息时,在控制台显示请检查数据库条目..但是没有条目。
任何人都可以告诉我回复,如何做到这一点
谢谢