62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
const text = "{{t('searchByName')}}";
|
||
|
||
const codeChunkRegex = /(?:\{\{)(.*?)(?:\}\})/gm;
|
||
const matches = text.match(codeChunkRegex);
|
||
|
||
if (matches) {
|
||
matches.forEach(
|
||
(codeChunk) => {
|
||
const codeContent = codeChunk.replace(codeChunkRegex, "$1");
|
||
|
||
console.log(codeContent);
|
||
}
|
||
)
|
||
}
|
||
|
||
type Module = any;
|
||
type Exception = any;
|
||
|
||
type TestResult = {
|
||
desc: string;
|
||
cost: number;
|
||
error?: {
|
||
code: 'exception' | 'mistake',
|
||
exception?: Exception;
|
||
};
|
||
};
|
||
/**
|
||
* 一个测试用例
|
||
* api是传入的api函数入口,
|
||
* modules是所有依赖的包
|
||
*/
|
||
type TestUnit = (api: Function, modules: Record<string, Module>) => TestResult[];
|
||
|
||
/**
|
||
* 测试用例注册:
|
||
* moduleName: 要测试的模块名
|
||
* apiName: 要测试的接口名
|
||
* unit: 测试用例
|
||
* dependencies: 依赖的其它包及包中的接口
|
||
*/
|
||
type Registery = (moduleName: string, apiName: string, unit: TestUnit, dependencies?: {
|
||
[M: string]: string[]
|
||
}) => void;
|
||
|
||
type RunResult = {
|
||
moduleResults: {
|
||
[M: string]: {
|
||
apiResults: {
|
||
[API: string]: {
|
||
result: TestResult[];
|
||
weight: number;
|
||
mark: number;
|
||
}
|
||
},
|
||
weight: number;
|
||
mark: number;
|
||
}
|
||
},
|
||
mark: number;
|
||
}
|
||
|
||
type Run = () => RunResult; |