koatty_validation 1.0.12 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -6
- package/dist/LICENSE +29 -0
- package/dist/README.md +106 -0
- package/dist/index.d.ts +402 -9
- package/dist/index.js +1277 -21
- package/dist/index.mjs +1219 -0
- package/dist/package.json +90 -0
- package/jest-html-reporters-attach/index.js +58 -0
- package/jest-html-reporters-attach/result.js +1 -0
- package/package.json +24 -20
- package/.eslintignore +0 -9
- package/.eslintrc.js +0 -43
- package/babel.config.js +0 -21
- package/commitlint.config.js +0 -14
- package/dist/decorator.d.ts +0 -237
- package/dist/decorator.js +0 -681
- package/dist/decorator.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/rule.d.ts +0 -83
- package/dist/rule.js +0 -291
- package/dist/rule.js.map +0 -1
- package/dist/util.d.ts +0 -108
- package/dist/util.js +0 -422
- package/dist/util.js.map +0 -1
- package/jest.config.js +0 -36
- package/jest_html_reporters.html +0 -60
- package/tsconfig.json +0 -67
package/dist/util.js
DELETED
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.plateNumber = exports.zipCode = exports.mobile = exports.idNumber = exports.cnName = exports.checkParamsType = exports.convertParamsType = exports.convertDtoParamsType = exports.plainToClass = exports.getOriginMetadata = exports.defineNewProperty = exports.recursiveGetMetadata = exports.setExpose = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
/**
|
|
6
|
-
* @ author: richen
|
|
7
|
-
* @ copyright: Copyright (c) - <richenlin(at)gmail.com>
|
|
8
|
-
* @ license: MIT
|
|
9
|
-
* @ version: 2020-03-20 11:34:38
|
|
10
|
-
*/
|
|
11
|
-
// tslint:disable-next-line: no-import-side-effect
|
|
12
|
-
require("reflect-metadata");
|
|
13
|
-
const helper = (0, tslib_1.__importStar)(require("koatty_lib"));
|
|
14
|
-
const rule_1 = require("./rule");
|
|
15
|
-
/**
|
|
16
|
-
* Set property as included in the process of transformation.
|
|
17
|
-
*
|
|
18
|
-
* @export
|
|
19
|
-
* @param {Object} object
|
|
20
|
-
* @param {(string | symbol)} propertyName
|
|
21
|
-
*/
|
|
22
|
-
function setExpose(object, propertyName) {
|
|
23
|
-
const types = Reflect.getMetadata("design:type", object, propertyName);
|
|
24
|
-
if (types) {
|
|
25
|
-
const originMap = getOriginMetadata(rule_1.PARAM_TYPE_KEY, object);
|
|
26
|
-
originMap.set(propertyName, types.name);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.setExpose = setExpose;
|
|
30
|
-
const functionPrototype = Object.getPrototypeOf(Function);
|
|
31
|
-
// get property of an object
|
|
32
|
-
// https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof
|
|
33
|
-
function ordinaryGetPrototypeOf(obj) {
|
|
34
|
-
const proto = Object.getPrototypeOf(obj);
|
|
35
|
-
if (typeof obj !== "function" || obj === functionPrototype) {
|
|
36
|
-
return proto;
|
|
37
|
-
}
|
|
38
|
-
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
|
|
39
|
-
// Try to determine the superclass constructor. Compatible implementations
|
|
40
|
-
// must either set __proto__ on a subclass constructor to the superclass constructor,
|
|
41
|
-
// or ensure each class has a valid `constructor` property on its prototype that
|
|
42
|
-
// points back to the constructor.
|
|
43
|
-
// If this is not the same as Function.[[Prototype]], then this is definitely inherited.
|
|
44
|
-
// This is the case when in ES6 or when using __proto__ in a compatible browser.
|
|
45
|
-
if (proto !== functionPrototype) {
|
|
46
|
-
return proto;
|
|
47
|
-
}
|
|
48
|
-
// If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
|
|
49
|
-
const prototype = obj.prototype;
|
|
50
|
-
const prototypeProto = prototype && Object.getPrototypeOf(prototype);
|
|
51
|
-
// tslint:disable-next-line: triple-equals
|
|
52
|
-
if (prototypeProto == undefined || prototypeProto === Object.prototype) {
|
|
53
|
-
return proto;
|
|
54
|
-
}
|
|
55
|
-
// If the constructor was not a function, then we cannot determine the heritage.
|
|
56
|
-
const constructor = prototypeProto.constructor;
|
|
57
|
-
if (typeof constructor !== "function") {
|
|
58
|
-
return proto;
|
|
59
|
-
}
|
|
60
|
-
// If we have some kind of self-reference, then we cannot determine the heritage.
|
|
61
|
-
if (constructor === obj) {
|
|
62
|
-
return proto;
|
|
63
|
-
}
|
|
64
|
-
// we have a pretty good guess at the heritage.
|
|
65
|
-
return constructor;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* get property metadata data
|
|
69
|
-
*
|
|
70
|
-
* @param {(string | symbol)} decoratorNameKey
|
|
71
|
-
* @param {*} target
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
function listPropertyData(decoratorNameKey, target, propertyKey) {
|
|
75
|
-
const originMap = getOriginMetadata(decoratorNameKey, target, propertyKey);
|
|
76
|
-
const data = {};
|
|
77
|
-
for (const [key, value] of originMap) {
|
|
78
|
-
data[key] = value;
|
|
79
|
-
}
|
|
80
|
-
return data;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* get metadata value of a metadata key on the prototype chain of an object and property
|
|
84
|
-
* @param metadataKey metadata key
|
|
85
|
-
* @param target the target of metadataKey
|
|
86
|
-
*/
|
|
87
|
-
function recursiveGetMetadata(metadataKey, target, propertyKey) {
|
|
88
|
-
// get metadata value of a metadata key on the prototype
|
|
89
|
-
// let metadata = Reflect.getOwnMetadata(metadataKey, target, propertyKey);
|
|
90
|
-
const metadata = listPropertyData(metadataKey, target, propertyKey) || {};
|
|
91
|
-
// get metadata value of a metadata key on the prototype chain
|
|
92
|
-
let parent = ordinaryGetPrototypeOf(target);
|
|
93
|
-
while (parent !== null) {
|
|
94
|
-
// metadata = Reflect.getOwnMetadata(metadataKey, parent, propertyKey);
|
|
95
|
-
const pMetadata = listPropertyData(metadataKey, parent, propertyKey);
|
|
96
|
-
if (pMetadata) {
|
|
97
|
-
for (const n in pMetadata) {
|
|
98
|
-
if (!metadata.hasOwnProperty(n)) {
|
|
99
|
-
metadata[n] = pMetadata[n];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
parent = ordinaryGetPrototypeOf(parent);
|
|
104
|
-
}
|
|
105
|
-
return metadata;
|
|
106
|
-
}
|
|
107
|
-
exports.recursiveGetMetadata = recursiveGetMetadata;
|
|
108
|
-
/**
|
|
109
|
-
* Dynamically add methods for target class types
|
|
110
|
-
*
|
|
111
|
-
* @param {Function} clazz
|
|
112
|
-
* @param {string} protoName
|
|
113
|
-
* @param {Function} func
|
|
114
|
-
*/
|
|
115
|
-
function defineNewProperty(clazz, protoName, func) {
|
|
116
|
-
const oldMethod = Reflect.get(clazz.prototype, protoName);
|
|
117
|
-
if (oldMethod) {
|
|
118
|
-
Reflect.defineProperty(clazz.prototype, protoName, {
|
|
119
|
-
writable: true,
|
|
120
|
-
value: function fn(...props) {
|
|
121
|
-
// process paramter
|
|
122
|
-
props = func(props);
|
|
123
|
-
// tslint:disable-next-line: no-invalid-this
|
|
124
|
-
return Reflect.apply(oldMethod, this, props);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.defineNewProperty = defineNewProperty;
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* @param {(string | symbol)} metadataKey
|
|
134
|
-
* @param {*} target
|
|
135
|
-
* @param {(string | symbol)} [propertyKey]
|
|
136
|
-
* @returns
|
|
137
|
-
*/
|
|
138
|
-
function getOriginMetadata(metadataKey, target, propertyKey) {
|
|
139
|
-
// filter Object.create(null)
|
|
140
|
-
if (typeof target === "object" && target.constructor) {
|
|
141
|
-
target = target.constructor;
|
|
142
|
-
}
|
|
143
|
-
if (propertyKey) {
|
|
144
|
-
// for property or method
|
|
145
|
-
if (!Reflect.hasMetadata(metadataKey, target, propertyKey)) {
|
|
146
|
-
Reflect.defineMetadata(metadataKey, new Map(), target, propertyKey);
|
|
147
|
-
}
|
|
148
|
-
return Reflect.getMetadata(metadataKey, target, propertyKey);
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
// for class
|
|
152
|
-
if (!Reflect.hasMetadata(metadataKey, target)) {
|
|
153
|
-
Reflect.defineMetadata(metadataKey, new Map(), target);
|
|
154
|
-
}
|
|
155
|
-
return Reflect.getMetadata(metadataKey, target);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
exports.getOriginMetadata = getOriginMetadata;
|
|
159
|
-
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* @export
|
|
163
|
-
* @param {*} clazz
|
|
164
|
-
* @param {*} data
|
|
165
|
-
* @param {boolean} [convert=false]
|
|
166
|
-
* @returns
|
|
167
|
-
*/
|
|
168
|
-
function plainToClass(clazz, data, convert = false) {
|
|
169
|
-
if (helper.isClass(clazz)) {
|
|
170
|
-
let cls;
|
|
171
|
-
if (!helper.isObject(data)) {
|
|
172
|
-
data = {};
|
|
173
|
-
}
|
|
174
|
-
if (data instanceof clazz) {
|
|
175
|
-
cls = data;
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
cls = Reflect.construct(clazz, []);
|
|
179
|
-
}
|
|
180
|
-
if (convert) {
|
|
181
|
-
return convertDtoParamsType(clazz, cls, data);
|
|
182
|
-
}
|
|
183
|
-
return Object.assign(cls, data);
|
|
184
|
-
}
|
|
185
|
-
return data;
|
|
186
|
-
}
|
|
187
|
-
exports.plainToClass = plainToClass;
|
|
188
|
-
/**
|
|
189
|
-
* convertDtoParamsType
|
|
190
|
-
*
|
|
191
|
-
* @param {*} clazz
|
|
192
|
-
* @param {*} cls
|
|
193
|
-
* @param {*} data
|
|
194
|
-
* @returns {*}
|
|
195
|
-
*/
|
|
196
|
-
function convertDtoParamsType(clazz, cls, data) {
|
|
197
|
-
if (Object.prototype.hasOwnProperty.call(cls, "_typeDef")) {
|
|
198
|
-
for (const key in cls) {
|
|
199
|
-
if (Object.prototype.hasOwnProperty.call(data, key)
|
|
200
|
-
&& Object.prototype.hasOwnProperty.call(cls._typeDef, key)) {
|
|
201
|
-
data[key] = convertParamsType(data[key], cls._typeDef[key]);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
const originMap = getOriginMetadata(rule_1.PARAM_TYPE_KEY, clazz);
|
|
207
|
-
for (const [key, type] of originMap) {
|
|
208
|
-
if (key && Object.prototype.hasOwnProperty.call(data, key)) {
|
|
209
|
-
cls[key] = convertParamsType(data[key], type);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return cls;
|
|
214
|
-
}
|
|
215
|
-
exports.convertDtoParamsType = convertDtoParamsType;
|
|
216
|
-
/**
|
|
217
|
-
* 绑定参数类型转换
|
|
218
|
-
*
|
|
219
|
-
* @param {*} param
|
|
220
|
-
* @param {string} type
|
|
221
|
-
* @returns {*}
|
|
222
|
-
*/
|
|
223
|
-
function convertParamsType(param, type) {
|
|
224
|
-
try {
|
|
225
|
-
switch (type) {
|
|
226
|
-
case "Number":
|
|
227
|
-
case "number":
|
|
228
|
-
if (helper.isNaN(param)) {
|
|
229
|
-
return NaN;
|
|
230
|
-
}
|
|
231
|
-
if (helper.isNumber(param)) {
|
|
232
|
-
return param;
|
|
233
|
-
}
|
|
234
|
-
if (helper.isNumberString(param)) {
|
|
235
|
-
return helper.toNumber(param);
|
|
236
|
-
}
|
|
237
|
-
return NaN;
|
|
238
|
-
case "Boolean":
|
|
239
|
-
case "boolean":
|
|
240
|
-
return !!param;
|
|
241
|
-
case "Array":
|
|
242
|
-
case "array":
|
|
243
|
-
case "Tuple":
|
|
244
|
-
case "tuple":
|
|
245
|
-
if (helper.isArray(param)) {
|
|
246
|
-
return param;
|
|
247
|
-
}
|
|
248
|
-
return helper.toArray(param);
|
|
249
|
-
case "String":
|
|
250
|
-
case "string":
|
|
251
|
-
if (helper.isString(param)) {
|
|
252
|
-
return param;
|
|
253
|
-
}
|
|
254
|
-
return helper.toString(param);
|
|
255
|
-
case "Null":
|
|
256
|
-
case "null":
|
|
257
|
-
return null;
|
|
258
|
-
case "Undefined":
|
|
259
|
-
case "undefined":
|
|
260
|
-
return undefined;
|
|
261
|
-
case "Bigint":
|
|
262
|
-
case "bigint":
|
|
263
|
-
if (typeof param === 'bigint') {
|
|
264
|
-
return param;
|
|
265
|
-
}
|
|
266
|
-
return BigInt(param);
|
|
267
|
-
// case "object":
|
|
268
|
-
// case "enum":
|
|
269
|
-
default: //any
|
|
270
|
-
return param;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
catch (err) {
|
|
274
|
-
return param;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
exports.convertParamsType = convertParamsType;
|
|
278
|
-
/**
|
|
279
|
-
* Check the base types.
|
|
280
|
-
*
|
|
281
|
-
* @param {*} value
|
|
282
|
-
* @param {string} type
|
|
283
|
-
* @returns {*}
|
|
284
|
-
*/
|
|
285
|
-
function checkParamsType(value, type) {
|
|
286
|
-
switch (type) {
|
|
287
|
-
case "Number":
|
|
288
|
-
case "number":
|
|
289
|
-
if (!helper.isNumber(value) || helper.isNaN(value)) {
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
return true;
|
|
293
|
-
case "Boolean":
|
|
294
|
-
case "boolean":
|
|
295
|
-
if (!helper.isBoolean(value)) {
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
return true;
|
|
299
|
-
case "Array":
|
|
300
|
-
case "array":
|
|
301
|
-
case "Tuple":
|
|
302
|
-
case "tuple":
|
|
303
|
-
if (!helper.isArray(value)) {
|
|
304
|
-
return false;
|
|
305
|
-
}
|
|
306
|
-
return true;
|
|
307
|
-
case "String":
|
|
308
|
-
case "string":
|
|
309
|
-
if (!helper.isString(value)) {
|
|
310
|
-
return false;
|
|
311
|
-
}
|
|
312
|
-
return true;
|
|
313
|
-
case "Object":
|
|
314
|
-
case "object":
|
|
315
|
-
case "Enum":
|
|
316
|
-
case "enum":
|
|
317
|
-
if (helper.isTrueEmpty(value)) {
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
return true;
|
|
321
|
-
case "Null":
|
|
322
|
-
case "null":
|
|
323
|
-
if (!helper.isNull(value)) {
|
|
324
|
-
return false;
|
|
325
|
-
}
|
|
326
|
-
return true;
|
|
327
|
-
case "Undefined":
|
|
328
|
-
case "undefined":
|
|
329
|
-
if (!helper.isUndefined(value)) {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
return true;
|
|
333
|
-
case "Bigint":
|
|
334
|
-
case "bigint":
|
|
335
|
-
if (typeof value !== 'bigint') {
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
return true;
|
|
339
|
-
default: //any
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
exports.checkParamsType = checkParamsType;
|
|
344
|
-
/**
|
|
345
|
-
* Checks if value is a chinese name.
|
|
346
|
-
*
|
|
347
|
-
* @param {string} value
|
|
348
|
-
* @returns {boolean}
|
|
349
|
-
*/
|
|
350
|
-
function cnName(value) {
|
|
351
|
-
const reg = /^([a-zA-Z0-9\u4e00-\u9fa5\·]{1,10})$/;
|
|
352
|
-
return reg.test(value);
|
|
353
|
-
}
|
|
354
|
-
exports.cnName = cnName;
|
|
355
|
-
/**
|
|
356
|
-
* Checks if value is a idCard number.
|
|
357
|
-
*
|
|
358
|
-
* @param {string} value
|
|
359
|
-
* @returns
|
|
360
|
-
*/
|
|
361
|
-
function idNumber(value) {
|
|
362
|
-
if (/^\d{15}$/.test(value)) {
|
|
363
|
-
return true;
|
|
364
|
-
}
|
|
365
|
-
if ((/^\d{17}[0-9X]$/).test(value)) {
|
|
366
|
-
const vs = '1,0,x,9,8,7,6,5,4,3,2'.split(',');
|
|
367
|
-
const ps = '7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2'.split(',');
|
|
368
|
-
const ss = value.toLowerCase().split('');
|
|
369
|
-
let r = 0;
|
|
370
|
-
for (let i = 0; i < 17; i++) {
|
|
371
|
-
r += ps[i] * ss[i];
|
|
372
|
-
}
|
|
373
|
-
const isOk = (vs[r % 11] === ss[17]);
|
|
374
|
-
return isOk;
|
|
375
|
-
}
|
|
376
|
-
return false;
|
|
377
|
-
}
|
|
378
|
-
exports.idNumber = idNumber;
|
|
379
|
-
/**
|
|
380
|
-
* Checks if value is a mobile phone number.
|
|
381
|
-
*
|
|
382
|
-
* @param {string} value
|
|
383
|
-
* @returns {boolean}
|
|
384
|
-
*/
|
|
385
|
-
function mobile(value) {
|
|
386
|
-
const reg = /^(13|14|15|16|17|18|19)\d{9}$/;
|
|
387
|
-
return reg.test(value);
|
|
388
|
-
}
|
|
389
|
-
exports.mobile = mobile;
|
|
390
|
-
/**
|
|
391
|
-
* Checks if value is a zipCode.
|
|
392
|
-
*
|
|
393
|
-
* @param {string} value
|
|
394
|
-
* @returns {boolean}
|
|
395
|
-
*/
|
|
396
|
-
function zipCode(value) {
|
|
397
|
-
const reg = /^\d{6}$/;
|
|
398
|
-
return reg.test(value);
|
|
399
|
-
}
|
|
400
|
-
exports.zipCode = zipCode;
|
|
401
|
-
/**
|
|
402
|
-
* Checks if value is a plateNumber.
|
|
403
|
-
*
|
|
404
|
-
* @param {string} value
|
|
405
|
-
* @returns {boolean}
|
|
406
|
-
*/
|
|
407
|
-
function plateNumber(value) {
|
|
408
|
-
// let reg = new RegExp('^(([\u4e00-\u9fa5][a-zA-Z]|[\u4e00-\u9fa5]{2}\d{2}|[\u4e00-\u9fa5]{2}[a-zA-Z])[-]?|([wW][Jj][\u4e00-\u9fa5]{1}[-]?)|([a-zA-Z]{2}))([A-Za-z0-9]{5}|[DdFf][A-HJ-NP-Za-hj-np-z0-9][0-9]{4}|[0-9]{5}[DdFf])$');
|
|
409
|
-
// let xReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
|
|
410
|
-
const xReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
|
|
411
|
-
// let cReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
|
|
412
|
-
const cReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
|
|
413
|
-
if (value.length === 7) {
|
|
414
|
-
return cReg.test(value);
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
//新能源车牌
|
|
418
|
-
return xReg.test(value);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
exports.plateNumber = plateNumber;
|
|
422
|
-
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;AAAA;;;;;GAKG;AACH,kDAAkD;AAClD,4BAA0B;AAC1B,gEAAqC;AAErC,iCAAwC;AAGxC;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,MAAc,EAAE,YAA6B;IACnE,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACvE,IAAI,KAAK,EAAE;QACP,MAAM,SAAS,GA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
|
-
|
|
5
|
-
// jest详细配置参见:
|
|
6
|
-
// https://jestjs.io/docs/en/configuration.html
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
preset: 'ts-jest',
|
|
10
|
-
testEnvironment: 'node', // 测试用例运行环境
|
|
11
|
-
testMatch: ['<rootDir>/test/**/*.(spec|test).[jt]s'], // 匹配测试用例的路径规则
|
|
12
|
-
reporters: [
|
|
13
|
-
'default',
|
|
14
|
-
'jest-html-reporters'
|
|
15
|
-
], // 测试用例报告
|
|
16
|
-
collectCoverage: true, // 是否收集测试时的覆盖率信息
|
|
17
|
-
coverageReporters: [
|
|
18
|
-
'html',
|
|
19
|
-
'lcov',
|
|
20
|
-
'json',
|
|
21
|
-
'text',
|
|
22
|
-
'clover',
|
|
23
|
-
'text-summary',
|
|
24
|
-
], // 收集测试时的覆盖率信息
|
|
25
|
-
// 将 `ts-jest` 的配置注入到运行时的全局变量中
|
|
26
|
-
globals: {
|
|
27
|
-
'ts-jest': {
|
|
28
|
-
// 是否使用 babel 配置来转译
|
|
29
|
-
babelConfig: true,
|
|
30
|
-
// 编译 Typescript 所依赖的配置
|
|
31
|
-
tsconfig: '<rootDir>/tsconfig.json',
|
|
32
|
-
// 是否启用报告诊断,这里是不启用
|
|
33
|
-
diagnostics: false,
|
|
34
|
-
},
|
|
35
|
-
}
|
|
36
|
-
};
|