chore: vitest support (#4026)

* chore: vitest

* chore: move test files

* chore: support vitest

* fix: exclude test files

* chore(ci): add test workflow

* feat: remove read env
This commit is contained in:
Finley Ge
2025-03-12 19:27:53 +08:00
committed by GitHub
parent 139e934345
commit bb30ca4859
32 changed files with 2393 additions and 892 deletions

21
test/utils/request.ts Normal file
View File

@@ -0,0 +1,21 @@
import { NextApiHandler } from '@fastgpt/service/common/middle/entry';
import { MockReqType } from '../mocks/request';
export async function Call<B = any, Q = any, R = any>(
handler: NextApiHandler<R>,
props?: MockReqType<B, Q>
) {
const { body = {}, query = {}, ...rest } = props || {};
return (await handler(
{
body: body,
query: query,
...(rest as any)
},
{} as any
)) as Promise<{
code: number;
data: R;
error?: any;
}>;
}