jest
title: koa & jest 单元测试 tags:
Koa
Jest
categories:
Nodejs
配置
app.js
const path = require('path');
const Koa = require('koa');
const app = new Koa();
const middleware = require('./middleware/index');
global.APP_PATH = __dirname;
global.join = (...args) => {
args.unshift(APP_PATH);
return path.join.apply(path, args);
};
const config = require(join('config'));
middleware(app, config);
app.use(async (ctx, next) => {
ctx.status = 404;
ctx.body = '404';
});
module.exports = app.listen(config.SERVER_PORT, err => {
if (err) {
console.error(err);
} else {
console.log(`http://localhost:${config.SERVER_PORT}`);
}
});goods.test.js
package.json
运行
Jest
matchers
参考
最后更新于
这有帮助吗?