koatty_cacheable 1.3.6 → 1.3.7
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/.rollup.config.js +63 -0
- package/CHANGELOG.md +1 -5
- package/dist/LICENSE +29 -0
- package/dist/README.md +57 -0
- package/dist/index.d.ts +47 -34
- package/dist/index.js +194 -166
- package/dist/index.mjs +173 -0
- package/dist/package.json +89 -0
- package/package.json +32 -23
- package/.eslintignore +0 -9
- package/.eslintrc.js +0 -43
- package/babel.config.js +0 -21
- package/commitlint.config.js +0 -14
- package/dist/index.js.map +0 -1
- package/jest.config.js +0 -36
- package/jest_html_reporters.html +0 -60
- package/tsconfig.json +0 -67
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @Author: richen
|
|
3
|
+
* @Date: 2022-05-27 11:35:38
|
|
4
|
+
* @License: BSD (3-Clause)
|
|
5
|
+
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
|
+
* @HomePage: https://koatty.org/
|
|
7
|
+
*/
|
|
8
|
+
import * as helper from 'koatty_lib';
|
|
9
|
+
import { DefaultLogger } from 'koatty_logger';
|
|
10
|
+
import { Store } from 'koatty_store';
|
|
11
|
+
import { IOCContainer } from 'koatty_container';
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* @Author: richen
|
|
15
|
+
* @Date: 2020-07-06 19:53:43
|
|
16
|
+
* @LastEditTime: 2021-12-02 16:20:52
|
|
17
|
+
* @Description:
|
|
18
|
+
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
19
|
+
*/
|
|
20
|
+
// cacheStore
|
|
21
|
+
const cacheStore = {
|
|
22
|
+
store: null
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* get instances of cacheStore
|
|
26
|
+
*
|
|
27
|
+
* @export
|
|
28
|
+
* @param {Application} app
|
|
29
|
+
* @returns {*} {CacheStore}
|
|
30
|
+
*/
|
|
31
|
+
async function GetCacheStore(app) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (cacheStore.store && cacheStore.store.getConnection) {
|
|
34
|
+
return cacheStore.store;
|
|
35
|
+
}
|
|
36
|
+
const opt = (_a = app.config("CacheStore", "db")) !== null && _a !== void 0 ? _a : {};
|
|
37
|
+
if (helper.isEmpty(opt)) {
|
|
38
|
+
DefaultLogger.Warn(`Missing CacheStore server configuration. Please write a configuration item with the key name 'CacheStore' in the db.ts file.`);
|
|
39
|
+
}
|
|
40
|
+
cacheStore.store = Store.getInstance(opt);
|
|
41
|
+
if (!helper.isFunction(cacheStore.store.getConnection)) {
|
|
42
|
+
throw Error(`CacheStore connection failed. `);
|
|
43
|
+
}
|
|
44
|
+
return cacheStore.store;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* initiation CacheStore connection and client.
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
async function InitCacheStore() {
|
|
51
|
+
const app = IOCContainer.getApp();
|
|
52
|
+
app && app.once("appStart", async function () {
|
|
53
|
+
await GetCacheStore(app);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Decorate this method to support caching. Redis server config from db.ts.
|
|
58
|
+
* The cache method returns a value to ensure that the next time the method is executed with the same parameters,
|
|
59
|
+
* the results can be obtained directly from the cache without the need to execute the method again.
|
|
60
|
+
*
|
|
61
|
+
* @export
|
|
62
|
+
* @param {string} cacheName cache name
|
|
63
|
+
* @param {number} [timeout=3600] cache timeout
|
|
64
|
+
* @returns {MethodDecorator}
|
|
65
|
+
*/
|
|
66
|
+
function CacheAble(cacheName, timeout = 3600) {
|
|
67
|
+
return (target, methodName, descriptor) => {
|
|
68
|
+
const componentType = IOCContainer.getType(target);
|
|
69
|
+
if (componentType !== "SERVICE" && componentType !== "COMPONENT") {
|
|
70
|
+
throw Error("This decorator only used in the service、component class.");
|
|
71
|
+
}
|
|
72
|
+
let identifier = IOCContainer.getIdentifier(target);
|
|
73
|
+
identifier = identifier || (target.constructor ? (target.constructor.name || "") : "");
|
|
74
|
+
const { value, configurable, enumerable } = descriptor;
|
|
75
|
+
descriptor = {
|
|
76
|
+
configurable,
|
|
77
|
+
enumerable,
|
|
78
|
+
writable: true,
|
|
79
|
+
async value(...props) {
|
|
80
|
+
let cacheFlag = true;
|
|
81
|
+
const store = await GetCacheStore(this.app).catch(() => {
|
|
82
|
+
cacheFlag = false;
|
|
83
|
+
DefaultLogger.Error("Get cache store instance failed.");
|
|
84
|
+
return null;
|
|
85
|
+
});
|
|
86
|
+
if (cacheFlag) {
|
|
87
|
+
// tslint:disable-next-line: one-variable-per-declaration
|
|
88
|
+
let key = "", res;
|
|
89
|
+
if (props && props.length > 0) {
|
|
90
|
+
key = `${identifier}:${methodName}:${helper.murmurHash(JSON.stringify(props))}`;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
key = `${identifier}:${methodName}`;
|
|
94
|
+
}
|
|
95
|
+
res = await store.hget(cacheName, key).catch(() => null);
|
|
96
|
+
if (!helper.isEmpty(res)) {
|
|
97
|
+
return JSON.parse(res);
|
|
98
|
+
}
|
|
99
|
+
// tslint:disable-next-line: no-invalid-this
|
|
100
|
+
res = await value.apply(this, props);
|
|
101
|
+
// prevent cache penetration
|
|
102
|
+
if (helper.isEmpty(res)) {
|
|
103
|
+
res = "";
|
|
104
|
+
timeout = 60;
|
|
105
|
+
}
|
|
106
|
+
// async set store
|
|
107
|
+
store.hset(cacheName, key, JSON.stringify(res), timeout).catch(() => null);
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
// tslint:disable-next-line: no-invalid-this
|
|
112
|
+
return value.apply(this, props);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
// bind app_ready hook event
|
|
117
|
+
InitCacheStore();
|
|
118
|
+
return descriptor;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Decorating the execution of this method will trigger a cache clear operation. Redis server config from db.ts.
|
|
123
|
+
*
|
|
124
|
+
* @export
|
|
125
|
+
* @param {string} cacheName cacheName cache name
|
|
126
|
+
* @param {eventTimes} [eventTime="Before"]
|
|
127
|
+
* @returns
|
|
128
|
+
*/
|
|
129
|
+
function CacheEvict(cacheName, eventTime = "Before") {
|
|
130
|
+
return (target, methodName, descriptor) => {
|
|
131
|
+
const componentType = IOCContainer.getType(target);
|
|
132
|
+
if (componentType !== "SERVICE" && componentType !== "COMPONENT") {
|
|
133
|
+
throw Error("This decorator only used in the service、component class.");
|
|
134
|
+
}
|
|
135
|
+
IOCContainer.getIdentifier(target);
|
|
136
|
+
const { value, configurable, enumerable } = descriptor;
|
|
137
|
+
descriptor = {
|
|
138
|
+
configurable,
|
|
139
|
+
enumerable,
|
|
140
|
+
writable: true,
|
|
141
|
+
async value(...props) {
|
|
142
|
+
let cacheFlag = true;
|
|
143
|
+
const store = await GetCacheStore(this.app).catch(() => {
|
|
144
|
+
cacheFlag = false;
|
|
145
|
+
DefaultLogger.Error("Get cache store instance failed.");
|
|
146
|
+
return null;
|
|
147
|
+
});
|
|
148
|
+
if (cacheFlag) {
|
|
149
|
+
if (eventTime === "Before") {
|
|
150
|
+
await store.del(cacheName).catch(() => null);
|
|
151
|
+
// tslint:disable-next-line: no-invalid-this
|
|
152
|
+
return value.apply(this, props);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
// tslint:disable-next-line: no-invalid-this
|
|
156
|
+
const res = await value.apply(this, props);
|
|
157
|
+
store.del(cacheName).catch(() => null);
|
|
158
|
+
return res;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// tslint:disable-next-line: no-invalid-this
|
|
163
|
+
return value.apply(this, props);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
// bind app_ready hook event
|
|
168
|
+
InitCacheStore();
|
|
169
|
+
return descriptor;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { CacheAble, CacheEvict, GetCacheStore };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koatty_cacheable",
|
|
3
|
+
"version": "1.3.7",
|
|
4
|
+
"description": "Cacheable for koatty.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
|
|
7
|
+
"build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
|
|
8
|
+
"build:js": "del-cli --force dist && npx rollup -c .rollup.config.js",
|
|
9
|
+
"build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
|
|
10
|
+
"build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
|
|
11
|
+
"eslint": "eslint --ext .ts,.js ./",
|
|
12
|
+
"prepublishOnly": "npm test && npm run build",
|
|
13
|
+
"prerelease": "npm test && npm run build",
|
|
14
|
+
"release": "standard-version",
|
|
15
|
+
"test": "npm run eslint && jest --passWithNoTests"
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"import": "./dist/index.mjs"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/thinkkoa/koatty_cacheable.git"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"cache",
|
|
28
|
+
"store",
|
|
29
|
+
"koatty",
|
|
30
|
+
"thinkkoa"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">10.0.0"
|
|
34
|
+
},
|
|
35
|
+
"author": {
|
|
36
|
+
"name": "richenlin",
|
|
37
|
+
"email": "richenlin@gmail.com"
|
|
38
|
+
},
|
|
39
|
+
"license": "BSD-3-Clause",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/thinkkoa/koatty_cacheable/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/thinkkoa/koatty_cacheable",
|
|
44
|
+
"maintainers": [
|
|
45
|
+
{
|
|
46
|
+
"name": "richenlin",
|
|
47
|
+
"email": "richenlin@gmail.com"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@commitlint/cli": "^17.x.x",
|
|
52
|
+
"@commitlint/config-conventional": "^17.x.x",
|
|
53
|
+
"@microsoft/api-documenter": "^7.x.x",
|
|
54
|
+
"@microsoft/api-extractor": "^7.x.x",
|
|
55
|
+
"@rollup/plugin-json": "^4.x.x",
|
|
56
|
+
"@types/jest": "^27.x.x",
|
|
57
|
+
"@types/koa": "^2.x.x",
|
|
58
|
+
"@types/node": "^16.x.x",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^5.x.x",
|
|
60
|
+
"@typescript-eslint/parser": "^5.x.x",
|
|
61
|
+
"conventional-changelog-cli": "^2.x.x",
|
|
62
|
+
"copyfiles": "^2.x.x",
|
|
63
|
+
"del-cli": "^4.x.x",
|
|
64
|
+
"eslint": "^8.x.x",
|
|
65
|
+
"eslint-plugin-jest": "^26.x.x",
|
|
66
|
+
"husky": "^4.x.x",
|
|
67
|
+
"jest": "^28.x.x",
|
|
68
|
+
"jest-html-reporters": "^3.x.x",
|
|
69
|
+
"rollup": "^2.x.x",
|
|
70
|
+
"rollup-plugin-typescript2": "^0.x.x",
|
|
71
|
+
"standard-version": "^9.x.x",
|
|
72
|
+
"ts-jest": "^28.x.x",
|
|
73
|
+
"ts-node": "^10.x.x",
|
|
74
|
+
"typescript": "^4.x.x"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"koatty_container": "^1.x.x",
|
|
78
|
+
"koatty_lib": "^1.x.x",
|
|
79
|
+
"koatty_logger": "^1.x.x",
|
|
80
|
+
"koatty_store": "^1.x.x",
|
|
81
|
+
"tslib": "^2.4.0"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"koatty_container": "^1.x.x",
|
|
85
|
+
"koatty_lib": "^1.x.x",
|
|
86
|
+
"koatty_logger": "^1.x.x",
|
|
87
|
+
"koatty_store": "^1.x.x"
|
|
88
|
+
}
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koatty_cacheable",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "Cacheable for koatty.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
6
|
+
"build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
|
|
7
|
+
"build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
|
|
8
|
+
"build:js": "del-cli --force dist && npx rollup -c .rollup.config.js",
|
|
9
|
+
"build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
|
|
10
|
+
"build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
|
|
7
11
|
"eslint": "eslint --ext .ts,.js ./",
|
|
8
12
|
"prepublishOnly": "npm test && npm run build",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"test": "npm run eslint && jest --passWithNoTests"
|
|
12
|
-
"test:cov": "jest --collectCoverage --detectOpenHandles",
|
|
13
|
-
"version": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
|
13
|
+
"prerelease": "npm test && npm run build",
|
|
14
|
+
"release": "standard-version",
|
|
15
|
+
"test": "npm run eslint && jest --passWithNoTests"
|
|
14
16
|
},
|
|
15
17
|
"main": "./dist/index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"import": "./dist/index.mjs"
|
|
21
|
+
},
|
|
16
22
|
"repository": {
|
|
17
23
|
"type": "git",
|
|
18
24
|
"url": "git+https://github.com/thinkkoa/koatty_cacheable.git"
|
|
@@ -42,26 +48,28 @@
|
|
|
42
48
|
}
|
|
43
49
|
],
|
|
44
50
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@commitlint/config-conventional": "^15.x.x",
|
|
51
|
+
"@commitlint/cli": "^17.x.x",
|
|
52
|
+
"@commitlint/config-conventional": "^17.x.x",
|
|
53
|
+
"@microsoft/api-documenter": "^7.x.x",
|
|
54
|
+
"@microsoft/api-extractor": "^7.x.x",
|
|
55
|
+
"@rollup/plugin-json": "^4.x.x",
|
|
51
56
|
"@types/jest": "^27.x.x",
|
|
52
57
|
"@types/koa": "^2.x.x",
|
|
53
58
|
"@types/node": "^16.x.x",
|
|
54
59
|
"@typescript-eslint/eslint-plugin": "^5.x.x",
|
|
55
60
|
"@typescript-eslint/parser": "^5.x.x",
|
|
56
61
|
"conventional-changelog-cli": "^2.x.x",
|
|
62
|
+
"copyfiles": "^2.x.x",
|
|
57
63
|
"del-cli": "^4.x.x",
|
|
58
64
|
"eslint": "^8.x.x",
|
|
59
|
-
"eslint-plugin-jest": "^
|
|
60
|
-
"husky": "^
|
|
61
|
-
"jest": "^
|
|
62
|
-
"jest-html-reporters": "^
|
|
65
|
+
"eslint-plugin-jest": "^26.x.x",
|
|
66
|
+
"husky": "^4.x.x",
|
|
67
|
+
"jest": "^28.x.x",
|
|
68
|
+
"jest-html-reporters": "^3.x.x",
|
|
69
|
+
"rollup": "^2.x.x",
|
|
70
|
+
"rollup-plugin-typescript2": "^0.x.x",
|
|
63
71
|
"standard-version": "^9.x.x",
|
|
64
|
-
"ts-jest": "^
|
|
72
|
+
"ts-jest": "^28.x.x",
|
|
65
73
|
"ts-node": "^10.x.x",
|
|
66
74
|
"typescript": "^4.x.x"
|
|
67
75
|
},
|
|
@@ -70,11 +78,12 @@
|
|
|
70
78
|
"koatty_lib": "^1.x.x",
|
|
71
79
|
"koatty_logger": "^1.x.x",
|
|
72
80
|
"koatty_store": "^1.x.x",
|
|
73
|
-
"tslib": "^2.
|
|
81
|
+
"tslib": "^2.4.0"
|
|
74
82
|
},
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"koatty_container": "^1.x.x",
|
|
85
|
+
"koatty_lib": "^1.x.x",
|
|
86
|
+
"koatty_logger": "^1.x.x",
|
|
87
|
+
"koatty_store": "^1.x.x"
|
|
79
88
|
}
|
|
80
89
|
}
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
root: true,
|
|
6
|
-
parser: '@typescript-eslint/parser',
|
|
7
|
-
extends: [
|
|
8
|
-
'plugin:@typescript-eslint/recommended', // 使用@typescript-eslint/eslint-plugin的推荐规则
|
|
9
|
-
'plugin:jest/recommended',
|
|
10
|
-
],
|
|
11
|
-
plugins: [
|
|
12
|
-
'@typescript-eslint',
|
|
13
|
-
'jest',
|
|
14
|
-
],
|
|
15
|
-
parserOptions: {
|
|
16
|
-
project: './tsconfig.json',
|
|
17
|
-
},
|
|
18
|
-
env: {
|
|
19
|
-
node: true,
|
|
20
|
-
mongo: true,
|
|
21
|
-
jest: true,
|
|
22
|
-
},
|
|
23
|
-
rules: {
|
|
24
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
25
|
-
// "@typescript-eslint/no-require-imports": "off",
|
|
26
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
27
|
-
"@typescript-eslint/member-ordering": "off",
|
|
28
|
-
"@typescript-eslint/consistent-type-assertions": "off",
|
|
29
|
-
"@typescript-eslint/no-param-reassign": "off",
|
|
30
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
31
|
-
"@typescript-eslint/no-empty-interface": "off",
|
|
32
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
33
|
-
"@typescript-eslint/ban-types": ["error",
|
|
34
|
-
{
|
|
35
|
-
"types": {
|
|
36
|
-
"Object": false,
|
|
37
|
-
"Function": false,
|
|
38
|
-
},
|
|
39
|
-
"extendDefaults": true
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
};
|
package/babel.config.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Description : babel配置
|
|
3
|
-
* @usage : 用于jest执行用例
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
presets: [
|
|
8
|
-
[
|
|
9
|
-
'@babel/preset-env',
|
|
10
|
-
{
|
|
11
|
-
targets: {
|
|
12
|
-
node: 'current',
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
'@babel/preset-typescript',
|
|
17
|
-
],
|
|
18
|
-
plugins: [
|
|
19
|
-
['@babel/plugin-proposal-decorators', { 'legacy': true }]
|
|
20
|
-
],
|
|
21
|
-
};
|
package/commitlint.config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
extends: ['@commitlint/config-conventional'],
|
|
6
|
-
rules: {
|
|
7
|
-
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
|
|
8
|
-
'type-empty': [2, 'never'],
|
|
9
|
-
'scope-enum': [0], // 不校验scope类型
|
|
10
|
-
'scope-empty': [0], // 不校验scope是否设置
|
|
11
|
-
'subject-case': [0], // 不校验描述的字符格式
|
|
12
|
-
'subject-min-length': [2, 'always', 5], // 描述至少5个字符
|
|
13
|
-
},
|
|
14
|
-
};
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA;;;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2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
|
|
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
|
-
};
|