测试时未定义主体

时间:2019-09-13 06:38:34

标签: javascript node.js express mocha chai

我正在使用Mocha和Chai对我的Express应用进行单元测试

在测试文件中时,我想使用 <android.support.v7.widget.AppCompatEditText android:id="@+id/input_edit_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="true" android:imeOptions="actionDone|flagNoExtractUi" android:inputType="textNoSuggestions|textVisiblePassword" android:textColor="@color/text_color_white"> 来解析对象,以便仅在测试结果中获得未定义的对象。

我在服务器req.body中已经具有正文解析器

我错过了什么我得到了答复。这是调用返回对象(app.js)

的路由
res.json(response)

1 个答案:

答案 0 :(得分:0)

看起来您在发出获取请求。

const options = 
{
 uri: 'http://localhost:3000/theFunction',
 method: 'POST',
 json: { "name": stackoverflow" } // json data you want to send. this will be populated as req.body
};

request(options, function (error, res, body) {
   expect(res.body).to.have.property('name')
   done();
});