@codefresh-io/service-base 7.0.4-beta → 7.2.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/infra/__tests__/smoke_test.spec.js +1 -1
- package/infra/config.js +8 -8
- package/infra/encryption/index.js +5 -5
- package/infra/encryption/safe.js +2 -5
- package/infra/eventbus.js +1 -4
- package/infra/express.js +4 -6
- package/infra/helper.js +1 -1
- package/infra/index.js +3 -5
- package/infra/logging.js +0 -3
- package/infra/mongo.js +0 -1
- package/infra/openapi-events.js +12 -8
- package/infra/process-events.js +0 -3
- package/infra/redis.js +7 -11
- package/infra/validation.js +2 -3
- package/package.json +16 -11
- package/.editorconfig +0 -9
- package/.eslintrc.js +0 -32
- package/.gitattributes +0 -2
- package/codefresh.yaml +0 -28
- package/jest.config.js +0 -186
package/infra/config.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
const _ = require('lodash');
|
|
4
2
|
const path = require('path');
|
|
5
3
|
const fs = require('fs');
|
|
@@ -15,8 +13,8 @@ function findAppRoot(dir = path.dirname(require.main.filename)) {
|
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
function getApproot() {
|
|
18
|
-
if ((process.env.NODE_ENV === 'test')
|
|
19
|
-
(_.includes(__dirname, 'node_modules'))) {
|
|
16
|
+
if ((process.env.NODE_ENV === 'test')
|
|
17
|
+
&& (_.includes(__dirname, 'node_modules'))) {
|
|
20
18
|
return path.resolve(__dirname).split('/node_modules')[0];
|
|
21
19
|
}
|
|
22
20
|
return findAppRoot();
|
|
@@ -52,12 +50,14 @@ base.eventbus = {
|
|
|
52
50
|
serviceName: name,
|
|
53
51
|
};
|
|
54
52
|
|
|
53
|
+
/** @type {import('pg').PoolConfig} */
|
|
55
54
|
base.postgres = {
|
|
56
55
|
host: process.env.POSTGRES_HOST || APPLICATION_DOMAIN,
|
|
57
|
-
port: process.env.POSTGRES_PORT || 5432,
|
|
56
|
+
port: Number.parseInt(process.env.POSTGRES_PORT || '5432', 10),
|
|
58
57
|
database: process.env.POSTGRES_DATABASE || 'postgres',
|
|
59
58
|
user: process.env.POSTGRES_USER || 'postgres',
|
|
60
59
|
password: process.env.POSTGRES_PASSWORD || 'postgres',
|
|
60
|
+
ssl: process.env.POSTGRES_SSL_ENABLE === 'true',
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
base.mongo = {
|
|
@@ -93,9 +93,9 @@ base.logger = {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
// human readable format
|
|
96
|
-
return `${options.timestamp()} ${options.level.toUpperCase()} >> `
|
|
97
|
-
`${options.message || ''}`
|
|
98
|
-
`${options.meta && Object.keys(options.meta).length ? ` << ${JSON.stringify(options.meta)}` : ''}`;
|
|
96
|
+
return `${options.timestamp()} ${options.level.toUpperCase()} >> `
|
|
97
|
+
+ `${options.message || ''}`
|
|
98
|
+
+ `${options.meta && Object.keys(options.meta).length ? ` << ${JSON.stringify(options.meta)}` : ''}`;
|
|
99
99
|
},
|
|
100
100
|
},
|
|
101
101
|
basePath: null,
|
|
@@ -11,7 +11,7 @@ function _encryptDecryptObjectValues(safeId, obj, keysToEncrypt = [], encrypt =
|
|
|
11
11
|
return Promise.resolve(obj);
|
|
12
12
|
}
|
|
13
13
|
const pairs = _.chain(keysToEncrypt)
|
|
14
|
-
.map(k => _.has(obj, k) && _.assign({ key: k, value: _.get(obj, k) }))
|
|
14
|
+
.map((k) => _.has(obj, k) && _.assign({ key: k, value: _.get(obj, k) }))
|
|
15
15
|
.compact()
|
|
16
16
|
.value();
|
|
17
17
|
|
|
@@ -19,8 +19,8 @@ function _encryptDecryptObjectValues(safeId, obj, keysToEncrypt = [], encrypt =
|
|
|
19
19
|
|
|
20
20
|
return safe.getOrCreateSafe(safeId)
|
|
21
21
|
.then((safeObj) => {
|
|
22
|
-
const Promises = pairs.map(kv => _encryptDecryptValue(safeObj, kv.value, encrypt)
|
|
23
|
-
.then(res => _.set(resObj, kv.key, res)));
|
|
22
|
+
const Promises = pairs.map((kv) => _encryptDecryptValue(safeObj, kv.value, encrypt)
|
|
23
|
+
.then((res) => _.set(resObj, kv.key, res)));
|
|
24
24
|
return Promise.all(Promises);
|
|
25
25
|
})
|
|
26
26
|
.then(() => resObj);
|
|
@@ -35,13 +35,13 @@ function decryptObjectValues(safeId, obj, keysToEncrypt) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function replaceEncryptedValues(encryptedObject = {}, keys = [], replaceWith = '*****') {
|
|
38
|
-
return Promise.map(keys, k => _.has(encryptedObject, k) && _.set(encryptedObject, k, replaceWith))
|
|
38
|
+
return Promise.map(keys, (k) => _.has(encryptedObject, k) && _.set(encryptedObject, k, replaceWith))
|
|
39
39
|
.then(() => encryptedObject);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
module.exports = {
|
|
43
43
|
encryptObjectValues,
|
|
44
44
|
decryptObjectValues,
|
|
45
|
-
getSafe: safeId => safe.getOrCreateSafe(safeId),
|
|
45
|
+
getSafe: (safeId) => safe.getOrCreateSafe(safeId),
|
|
46
46
|
replaceEncryptedValues,
|
|
47
47
|
};
|
package/infra/encryption/safe.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const { randomUUID } = require('node:crypto');
|
|
3
2
|
const _ = require('lodash');
|
|
4
3
|
const Promise = require('bluebird');
|
|
5
|
-
const uuid = require('node-uuid');
|
|
6
4
|
const crypto = require('crypto');
|
|
7
5
|
|
|
8
6
|
const config = require('../config');
|
|
@@ -45,7 +43,7 @@ function getOrCreateSafe(safeId) {
|
|
|
45
43
|
|
|
46
44
|
const newSafe = {
|
|
47
45
|
_id: safeId,
|
|
48
|
-
key: (
|
|
46
|
+
key: (Buffer.from(randomUUID())).toString('base64'), // eslint-disable-line
|
|
49
47
|
};
|
|
50
48
|
return collection.insertOne(newSafe)
|
|
51
49
|
.then(() => new Safe(newSafe))
|
|
@@ -113,7 +111,6 @@ Safe.prototype.write_crypto = function (plaintext) { // eslint-disable-line
|
|
|
113
111
|
return deferred.promise;
|
|
114
112
|
};
|
|
115
113
|
|
|
116
|
-
|
|
117
114
|
Safe.prototype.read = Safe.prototype.read_crypto;
|
|
118
115
|
Safe.prototype.write = Safe.prototype.write_crypto;
|
|
119
116
|
|
package/infra/eventbus.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
const Promise = require('bluebird');
|
|
4
2
|
const eventBus = require('@codefresh-io/eventbus');
|
|
5
3
|
const monitor = require('@codefresh-io/cf-monitor');
|
|
@@ -39,6 +37,7 @@ class Eventbus {
|
|
|
39
37
|
database: this.config.postgres.database,
|
|
40
38
|
user: this.config.postgres.user,
|
|
41
39
|
password: this.config.postgres.password,
|
|
40
|
+
ssl: this.config.postgres.ssl,
|
|
42
41
|
},
|
|
43
42
|
microServiceName: this.config.eventbus.serviceName,
|
|
44
43
|
});
|
|
@@ -59,7 +58,6 @@ class Eventbus {
|
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
|
|
62
|
-
|
|
63
61
|
/**
|
|
64
62
|
* stops the connection to eventbus
|
|
65
63
|
* @returns {*}
|
|
@@ -119,5 +117,4 @@ class Eventbus {
|
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
|
|
123
120
|
module.exports = new Eventbus();
|
package/infra/express.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
const Promise = require('bluebird');
|
|
3
2
|
const express = require('express');
|
|
4
3
|
const compression = require('compression');
|
|
@@ -122,9 +121,9 @@ class Express {
|
|
|
122
121
|
const statusCode = err.statusCode || 500;
|
|
123
122
|
// check if err object has overridden toString method
|
|
124
123
|
// before sending toString() response to prevent [object Object] responses
|
|
125
|
-
const message = err.toString === Object.prototype.toString
|
|
126
|
-
(err.message || 'Internal server error')
|
|
127
|
-
err.toString();
|
|
124
|
+
const message = err.toString === Object.prototype.toString
|
|
125
|
+
? (err.message || 'Internal server error')
|
|
126
|
+
: err.toString();
|
|
128
127
|
res.status(statusCode).send({ message });
|
|
129
128
|
});
|
|
130
129
|
});
|
|
@@ -154,10 +153,9 @@ class Express {
|
|
|
154
153
|
.then((ret) => {
|
|
155
154
|
res.send(ret);
|
|
156
155
|
})
|
|
157
|
-
.catch(err => next(err));
|
|
156
|
+
.catch((err) => next(err));
|
|
158
157
|
};
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
|
|
162
|
-
|
|
163
161
|
module.exports = new Express();
|
package/infra/helper.js
CHANGED
package/infra/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
const monitor = require('@codefresh-io/cf-monitor');
|
|
4
2
|
|
|
5
3
|
monitor.init();
|
|
6
4
|
const Promise = require('bluebird'); // jshint ignore:line
|
|
5
|
+
const cflogs = require('cf-logs');
|
|
6
|
+
const { openapi } = require('@codefresh-io/cf-openapi');
|
|
7
7
|
const config = require('./config');
|
|
8
8
|
const eventbus = require('./eventbus');
|
|
9
9
|
const mongo = require('./mongo');
|
|
@@ -11,8 +11,6 @@ const processEvents = require('./process-events');
|
|
|
11
11
|
const express = require('./express');
|
|
12
12
|
const logging = require('./logging');
|
|
13
13
|
const redis = require('./redis');
|
|
14
|
-
const cflogs = require('cf-logs');
|
|
15
|
-
const { openapi } = require('@codefresh-io/cf-openapi');
|
|
16
14
|
const { publishInterface, subscribeInterface } = require('./openapi-events');
|
|
17
15
|
|
|
18
16
|
let logger;
|
|
@@ -87,7 +85,7 @@ class Microservice {
|
|
|
87
85
|
openapi.events().setSubscribeInterface(subscribeInterface);
|
|
88
86
|
}
|
|
89
87
|
})
|
|
90
|
-
.then(() => express.init(config, app => initFn(app, eventbus), opt))
|
|
88
|
+
.then(() => express.init(config, (app) => initFn(app, eventbus), opt))
|
|
91
89
|
.then(() => {
|
|
92
90
|
logger.info('Initialization completed');
|
|
93
91
|
this.markAsReady();
|
package/infra/logging.js
CHANGED
package/infra/mongo.js
CHANGED
package/infra/openapi-events.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
const eventbus = require('./eventbus');
|
|
2
2
|
|
|
3
|
-
const publishInterface = (
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const publishInterface = (aggregateId) => {
|
|
4
|
+
eventbus.publish(
|
|
5
|
+
'openapi.push',
|
|
6
|
+
{ aggregateId },
|
|
7
|
+
true,
|
|
8
|
+
true,
|
|
9
|
+
);
|
|
10
|
+
};
|
|
6
11
|
|
|
7
12
|
const subscribeInterface = (handler) => {
|
|
8
|
-
eventbus.subscribe(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
+
eventbus.subscribe(
|
|
14
|
+
'openapi.push',
|
|
15
|
+
async (data) => handler(data.aggregateId),
|
|
16
|
+
);
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
module.exports = {
|
package/infra/process-events.js
CHANGED
package/infra/redis.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
const Promise = require('bluebird');
|
|
4
2
|
const monitor = require('@codefresh-io/cf-monitor');
|
|
5
3
|
const redis = require('redis');
|
|
@@ -24,14 +22,13 @@ class Redis {
|
|
|
24
22
|
deferred.resolve();
|
|
25
23
|
}, 30000);
|
|
26
24
|
|
|
27
|
-
this.client =
|
|
28
|
-
redis.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
25
|
+
this.client = redis.createClient({
|
|
26
|
+
host: config.redis.url,
|
|
27
|
+
port: config.redis.port,
|
|
28
|
+
password: config.redis.password,
|
|
29
|
+
db: config.redis.db,
|
|
30
|
+
tls: config.redis.tls,
|
|
31
|
+
});
|
|
35
32
|
|
|
36
33
|
this.client.on('ready', () => {
|
|
37
34
|
logger.info('Redis client ready');
|
|
@@ -55,7 +52,6 @@ class Redis {
|
|
|
55
52
|
return deferred.promise;
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
|
|
59
55
|
/**
|
|
60
56
|
* stops the connection to redis
|
|
61
57
|
* @returns {*}
|
package/infra/validation.js
CHANGED
|
@@ -36,7 +36,6 @@ const customJsonSchemaStringJoi = Joi.extend((joi) => ({ // eslint-disable-line
|
|
|
36
36
|
}));
|
|
37
37
|
Joi.jsonSchemaString = customJsonSchemaStringJoi.jsonSchemaString;
|
|
38
38
|
|
|
39
|
-
|
|
40
39
|
function validateField(field, val, options = { optional: false }) {
|
|
41
40
|
if (val === undefined && _.get(options, 'optional')) {
|
|
42
41
|
return Promise.resolve();
|
|
@@ -50,8 +49,8 @@ function validateFields(partialObject, options) {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
function validateWithContext(obj, context) {
|
|
53
|
-
return this.validate(
|
|
54
|
-
.then(normalized => _.omit(normalized, Object.keys(context)));
|
|
52
|
+
return this.validate({ ...obj, ...context })
|
|
53
|
+
.then((normalized) => _.omit(normalized, Object.keys(context)));
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefresh-io/service-base",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cf-openapi": "./node_modules/cf-openapi/bin/cf-openapi"
|
|
8
8
|
},
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": "
|
|
10
|
+
"node": "^20.0.0 || ^22.0.0"
|
|
11
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.js",
|
|
14
|
+
"infra/**/*"
|
|
15
|
+
],
|
|
12
16
|
"scripts": {
|
|
13
17
|
"test": "(find . -not -path './node_modules/*' -path '*/*.spec.js' | grep -v '__tests__' | NODE_ENV=test xargs mocha) && jest",
|
|
14
18
|
"start": "node index.js",
|
|
15
|
-
"
|
|
19
|
+
"lint": "eslint infra/**",
|
|
20
|
+
"build": "echo 'No build step'"
|
|
16
21
|
},
|
|
17
22
|
"repository": {
|
|
18
23
|
"type": "git",
|
|
@@ -33,9 +38,9 @@
|
|
|
33
38
|
"homepage": "https://github.com/codefresh-io/service-base#readme",
|
|
34
39
|
"dependencies": {
|
|
35
40
|
"@codefresh-io/authenticated-entity": "^2.17.1",
|
|
36
|
-
"@codefresh-io/cf-monitor": "^12.
|
|
41
|
+
"@codefresh-io/cf-monitor": "^12.15.0",
|
|
37
42
|
"@codefresh-io/cf-openapi": "^0.7.20",
|
|
38
|
-
"@codefresh-io/eventbus": "^2.
|
|
43
|
+
"@codefresh-io/eventbus": "^2.3.0",
|
|
39
44
|
"@codefresh-io/http-infra": "^1.8.15",
|
|
40
45
|
"@codefresh-io/internal-service-config": "^1.0.3",
|
|
41
46
|
"@wegolook/joi-objectid": "^2.4.0",
|
|
@@ -52,9 +57,8 @@
|
|
|
52
57
|
"js-yaml": "^3.13.1",
|
|
53
58
|
"lodash": "4.17.21",
|
|
54
59
|
"method-override": "^3.0.0",
|
|
55
|
-
"mongodb": "
|
|
60
|
+
"mongodb": "^6.15.0",
|
|
56
61
|
"morgan": "^1.9.1",
|
|
57
|
-
"node-uuid": "^1.4.8",
|
|
58
62
|
"proxyquire": "^1.8.0",
|
|
59
63
|
"queue": "^4.2.1",
|
|
60
64
|
"redis": "^3.1.0",
|
|
@@ -63,13 +67,14 @@
|
|
|
63
67
|
},
|
|
64
68
|
"devDependencies": {
|
|
65
69
|
"@shelf/jest-mongodb": "^4.2.0",
|
|
66
|
-
"eslint": "^
|
|
67
|
-
"eslint-config-airbnb-base": "^
|
|
68
|
-
"eslint-plugin-import": "^2.
|
|
70
|
+
"eslint": "^8.52.0",
|
|
71
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
72
|
+
"eslint-plugin-import": "^2.31.0",
|
|
69
73
|
"eslint-plugin-jest": "^27.6.3",
|
|
70
74
|
"eslint-plugin-mocha": "^4.12.1",
|
|
71
75
|
"jest": "^29.7.0",
|
|
72
76
|
"mocha": "^8.2.1",
|
|
73
77
|
"mongodb-memory-server": "^9.1.6"
|
|
74
|
-
}
|
|
78
|
+
},
|
|
79
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
75
80
|
}
|
package/.editorconfig
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
'plugins': [
|
|
3
|
-
'mocha',
|
|
4
|
-
'jest'
|
|
5
|
-
],
|
|
6
|
-
'extends': 'airbnb-base',
|
|
7
|
-
'rules': {
|
|
8
|
-
'indent': ['error', 4, { 'SwitchCase': 1 }],
|
|
9
|
-
'no-underscore-dangle': [0],
|
|
10
|
-
'max-len': ['error', {
|
|
11
|
-
'code': 140,
|
|
12
|
-
'ignoreComments': true
|
|
13
|
-
}],
|
|
14
|
-
'no-console': 0,
|
|
15
|
-
"object-curly-newline": ["error", {
|
|
16
|
-
"ObjectPattern": { "multiline": true },
|
|
17
|
-
}],
|
|
18
|
-
"newline-per-chained-call": ["error", {
|
|
19
|
-
"ignoreChainWithDepth": 10,
|
|
20
|
-
}],
|
|
21
|
-
"object-property-newline": ["error", {
|
|
22
|
-
"allowAllPropertiesOnSameLine": true,
|
|
23
|
-
}]
|
|
24
|
-
},
|
|
25
|
-
'env': {
|
|
26
|
-
'mocha': true,
|
|
27
|
-
'jest': true
|
|
28
|
-
},
|
|
29
|
-
"globals": {
|
|
30
|
-
"negativeAssertion": true
|
|
31
|
-
}
|
|
32
|
-
};
|
package/.gitattributes
DELETED
package/codefresh.yaml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
version: '1.0'
|
|
2
|
-
steps:
|
|
3
|
-
main_clone:
|
|
4
|
-
title: 'Cloning main repository...'
|
|
5
|
-
type: git-clone
|
|
6
|
-
repo: '${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}'
|
|
7
|
-
revision: ${{CF_BRANCH}}
|
|
8
|
-
|
|
9
|
-
install_dependencies:
|
|
10
|
-
title: 'Installing testing dependencies'
|
|
11
|
-
image: node:${{NODE_VERSION}}
|
|
12
|
-
commands:
|
|
13
|
-
- yarn install --frozen-lockfile
|
|
14
|
-
|
|
15
|
-
eslint:
|
|
16
|
-
title: 'Running linting logic'
|
|
17
|
-
image: node:${{NODE_VERSION}}
|
|
18
|
-
commands:
|
|
19
|
-
- yarn eslint
|
|
20
|
-
|
|
21
|
-
deploy_to_npm:
|
|
22
|
-
type: npm-publish
|
|
23
|
-
arguments:
|
|
24
|
-
NPM_TOKEN: '${{NPM_TOKEN}}'
|
|
25
|
-
DIR: '${{CF_REPO_NAME}}'
|
|
26
|
-
when:
|
|
27
|
-
branch:
|
|
28
|
-
only: [ master ]
|
package/jest.config.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
-
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
preset: '@shelf/jest-mongodb',
|
|
6
|
-
// All imported modules in your tests should be mocked automatically
|
|
7
|
-
// automock: false,
|
|
8
|
-
|
|
9
|
-
// Stop running tests after `n` failures
|
|
10
|
-
// bail: 0,
|
|
11
|
-
|
|
12
|
-
// Respect "browser" field in package.json when resolving modules
|
|
13
|
-
// browser: false,
|
|
14
|
-
|
|
15
|
-
// The directory where Jest should store its cached dependency information
|
|
16
|
-
// cacheDirectory: "/private/var/folders/f8/9_8h1fmx21d1vmcpl0nnyjw00000gn/T/jest_dx",
|
|
17
|
-
|
|
18
|
-
// Automatically clear mock calls and instances between every test
|
|
19
|
-
clearMocks: true,
|
|
20
|
-
|
|
21
|
-
// Indicates whether the coverage information should be collected while executing the test
|
|
22
|
-
// collectCoverage: false,
|
|
23
|
-
|
|
24
|
-
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
25
|
-
// collectCoverageFrom: null,
|
|
26
|
-
|
|
27
|
-
// The directory where Jest should output its coverage files
|
|
28
|
-
coverageDirectory: 'coverage',
|
|
29
|
-
|
|
30
|
-
// An array of regexp pattern strings used to skip coverage collection
|
|
31
|
-
coveragePathIgnorePatterns: [
|
|
32
|
-
'/node_modules/',
|
|
33
|
-
],
|
|
34
|
-
|
|
35
|
-
// A list of reporter names that Jest uses when writing coverage reports
|
|
36
|
-
// coverageReporters: [
|
|
37
|
-
// "json",
|
|
38
|
-
// "text",
|
|
39
|
-
// "lcov",
|
|
40
|
-
// "clover"
|
|
41
|
-
// ],
|
|
42
|
-
|
|
43
|
-
// An object that configures minimum threshold enforcement for coverage results
|
|
44
|
-
// coverageThreshold: null,
|
|
45
|
-
|
|
46
|
-
// A path to a custom dependency extractor
|
|
47
|
-
// dependencyExtractor: null,
|
|
48
|
-
|
|
49
|
-
// Make calling deprecated APIs throw helpful error messages
|
|
50
|
-
// errorOnDeprecated: false,
|
|
51
|
-
|
|
52
|
-
// Force coverage collection from ignored files using an array of glob patterns
|
|
53
|
-
// forceCoverageMatch: [],
|
|
54
|
-
|
|
55
|
-
// A path to a module which exports an async function that is triggered once before all test suites
|
|
56
|
-
// globalSetup: null,
|
|
57
|
-
|
|
58
|
-
// A path to a module which exports an async function that is triggered once after all test suites
|
|
59
|
-
// globalTeardown: null,
|
|
60
|
-
|
|
61
|
-
// A set of global variables that need to be available in all test environments
|
|
62
|
-
// globals: {},
|
|
63
|
-
|
|
64
|
-
// An array of directory names to be searched recursively up from the requiring module's location
|
|
65
|
-
// moduleDirectories: [
|
|
66
|
-
// "node_modules"
|
|
67
|
-
// ],
|
|
68
|
-
|
|
69
|
-
// An array of file extensions your modules use
|
|
70
|
-
// moduleFileExtensions: [
|
|
71
|
-
// "js",
|
|
72
|
-
// "json",
|
|
73
|
-
// "jsx",
|
|
74
|
-
// "ts",
|
|
75
|
-
// "tsx",
|
|
76
|
-
// "node"
|
|
77
|
-
// ],
|
|
78
|
-
|
|
79
|
-
// A map from regular expressions to module names that allow to stub out resources with a single module
|
|
80
|
-
// moduleNameMapper: {},
|
|
81
|
-
|
|
82
|
-
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
83
|
-
// modulePathIgnorePatterns: [],
|
|
84
|
-
|
|
85
|
-
// Activates notifications for test results
|
|
86
|
-
// notify: false,
|
|
87
|
-
|
|
88
|
-
// An enum that specifies notification mode. Requires { notify: true }
|
|
89
|
-
// notifyMode: "failure-change",
|
|
90
|
-
|
|
91
|
-
// A preset that is used as a base for Jest's configuration
|
|
92
|
-
// preset: null,
|
|
93
|
-
|
|
94
|
-
// Run tests from one or more projects
|
|
95
|
-
// projects: null,
|
|
96
|
-
|
|
97
|
-
// Use this configuration option to add custom reporters to Jest
|
|
98
|
-
// reporters: undefined,
|
|
99
|
-
|
|
100
|
-
// Automatically reset mock state between every test
|
|
101
|
-
// resetMocks: false,
|
|
102
|
-
|
|
103
|
-
// Reset the module registry before running each individual test
|
|
104
|
-
// resetModules: false,
|
|
105
|
-
|
|
106
|
-
// A path to a custom resolver
|
|
107
|
-
// resolver: null,
|
|
108
|
-
|
|
109
|
-
// Automatically restore mock state between every test
|
|
110
|
-
// restoreMocks: false,
|
|
111
|
-
|
|
112
|
-
// The root directory that Jest should scan for tests and modules within
|
|
113
|
-
// rootDir: null,
|
|
114
|
-
|
|
115
|
-
// A list of paths to directories that Jest should use to search for files in
|
|
116
|
-
// roots: [
|
|
117
|
-
// "<rootDir>"
|
|
118
|
-
// ],
|
|
119
|
-
|
|
120
|
-
// Allows you to use a custom runner instead of Jest's default test runner
|
|
121
|
-
// runner: "jest-runner",
|
|
122
|
-
|
|
123
|
-
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
124
|
-
// setupFiles: [],
|
|
125
|
-
|
|
126
|
-
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
127
|
-
// setupFilesAfterEnv: [],
|
|
128
|
-
|
|
129
|
-
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
130
|
-
// snapshotSerializers: [],
|
|
131
|
-
|
|
132
|
-
// The test environment that will be used for testing
|
|
133
|
-
testEnvironment: 'node',
|
|
134
|
-
|
|
135
|
-
// Options that will be passed to the testEnvironment
|
|
136
|
-
// testEnvironmentOptions: {},
|
|
137
|
-
|
|
138
|
-
// Adds a location field to test results
|
|
139
|
-
// testLocationInResults: false,
|
|
140
|
-
|
|
141
|
-
// The glob patterns Jest uses to detect test files
|
|
142
|
-
testMatch: [
|
|
143
|
-
'**/__tests__/**/*.[jt]s?(x)',
|
|
144
|
-
],
|
|
145
|
-
|
|
146
|
-
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
147
|
-
// testPathIgnorePatterns: [
|
|
148
|
-
// "/node_modules/"
|
|
149
|
-
// ],
|
|
150
|
-
|
|
151
|
-
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
152
|
-
// testRegex: [
|
|
153
|
-
// ],
|
|
154
|
-
|
|
155
|
-
// This option allows the use of a custom results processor
|
|
156
|
-
// testResultsProcessor: null,
|
|
157
|
-
|
|
158
|
-
// This option allows use of a custom test runner
|
|
159
|
-
// testRunner: "jasmine2",
|
|
160
|
-
|
|
161
|
-
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
|
162
|
-
// testURL: "http://localhost",
|
|
163
|
-
|
|
164
|
-
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
|
165
|
-
// timers: "real",
|
|
166
|
-
|
|
167
|
-
// A map from regular expressions to paths to transformers
|
|
168
|
-
// transform: null,
|
|
169
|
-
|
|
170
|
-
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
171
|
-
// transformIgnorePatterns: [
|
|
172
|
-
// "/node_modules/"
|
|
173
|
-
// ],
|
|
174
|
-
|
|
175
|
-
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
176
|
-
// unmockedModulePathPatterns: undefined,
|
|
177
|
-
|
|
178
|
-
// Indicates whether each individual test should be reported during the run
|
|
179
|
-
// verbose: null,
|
|
180
|
-
|
|
181
|
-
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
182
|
-
// watchPathIgnorePatterns: [],
|
|
183
|
-
|
|
184
|
-
// Whether to use watchman for file crawling
|
|
185
|
-
// watchman: true,
|
|
186
|
-
};
|