更新
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
// https://molunerfinn.com/Use-Jest-To-Test-Vue-Koa/#Koa%E5%90%8E%E7%AB%AFApi%E6%B5%8B%E8%AF%95
|
||||
//https://jestjs.io/docs/api#testeachtablename-fn-timeout
|
||||
//Jest CLI选项 : https://runebook.dev/zh-CN/docs/jest/cli#--forceexit
|
||||
//匹配器:https://www.jianshu.com/p/c1b5676c1edd
|
||||
const bamboo = require('./lib/main')
|
||||
const glob = require("glob")
|
||||
const path = require('path')
|
||||
import request from 'supertest';
|
||||
|
||||
let server = ""
|
||||
let list = []
|
||||
|
||||
/*当前根目录*/
|
||||
function isPath(args) {
|
||||
return path.resolve('./' + (args || ""))
|
||||
}
|
||||
|
||||
function load(directory) {
|
||||
const path_root = isPath()
|
||||
let files = glob.sync(directory)
|
||||
files = files.map(item => {
|
||||
const parse = path.parse(item);
|
||||
parse.father = path.basename(path.resolve(parse.dir, '..'))
|
||||
parse.file_father = path.basename(path.resolve(parse.dir + '/' + parse.name, '..'))
|
||||
return {
|
||||
parse,
|
||||
res: require(path.resolve(path_root + "/" + item))
|
||||
}
|
||||
})
|
||||
return files
|
||||
}
|
||||
|
||||
list = load("app/*/test/*.js")
|
||||
|
||||
beforeAll(() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
bamboo.fullList.push(async (app) => {
|
||||
server = app.server
|
||||
//回复测试数据镜像sql文件
|
||||
await app.db.tool.reduction()
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
|
||||
});
|
||||
afterAll(() => {
|
||||
server.close();
|
||||
console.log('服务器关闭!');
|
||||
});
|
||||
|
||||
|
||||
describe.each(list)('测试清单名称:$res.describe_name', (testDescribe) => {
|
||||
test.each(testDescribe.res.testList)('测试名称:$test_name', async (o) => await o.fun(request, server));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user