微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

supertest

编程之家收集整理的这个编程导航主要介绍了supertest编程之家,现在分享给大家,也给大家做个参考。

supertest 介绍

supertest是nodejs开发单元测试模块。

安装

npm install supertest --save-dev

SuperTest适用于任何测试框架,这里是一个不使用任何测试框架的例子: 

const request = require('supertest');

const express = require('express');

const app = express();

app.get('/user',function(req,res) {

res.status(200).json({ name: 'john' });

});

request(app)

.get('/user')

.expect('Content-Type',/json/)

.expect('Content-Length','15')

.expect(200)

.end(function(err,res) {

if (err) throw err;

});

 

GitHub:https://github.com/visionmedia/supertest

网站描述:nodejs开发单元测试

supertest

官方网站:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。