@naturalcycles/dev-lib 16.2.1 → 16.3.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/cfg/vitest.config.mjs
CHANGED
package/dist/test.util.js
CHANGED
|
@@ -19,12 +19,10 @@ function runTest(opt = {}) {
|
|
|
19
19
|
}
|
|
20
20
|
function runVitest(opt) {
|
|
21
21
|
const { integration, manual } = opt;
|
|
22
|
+
const { CPU_LIMIT } = process.env;
|
|
22
23
|
const processArgs = process.argv.slice(3);
|
|
23
24
|
const args = [...processArgs];
|
|
24
|
-
const
|
|
25
|
-
const env = {
|
|
26
|
-
TZ,
|
|
27
|
-
};
|
|
25
|
+
const env = {};
|
|
28
26
|
if (integration) {
|
|
29
27
|
Object.assign(env, {
|
|
30
28
|
TEST_TYPE: 'integration',
|
|
@@ -35,6 +33,13 @@ function runVitest(opt) {
|
|
|
35
33
|
TEST_TYPE: 'manual',
|
|
36
34
|
});
|
|
37
35
|
}
|
|
36
|
+
if (CPU_LIMIT) {
|
|
37
|
+
const cpuLimit = Number(CPU_LIMIT);
|
|
38
|
+
Object.assign(env, {
|
|
39
|
+
VITEST_MIN_FORKS: cpuLimit,
|
|
40
|
+
VITEST_MAX_FORKS: cpuLimit,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
38
43
|
nodejs_lib_1.exec2.spawn('vitest', {
|
|
39
44
|
args: (0, js_lib_1._uniq)(args),
|
|
40
45
|
logFinish: false,
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare function testOffline(): void;
|
|
5
5
|
/**
|
|
6
|
-
* Undo/reset the
|
|
6
|
+
* Undo/reset the testOffline() function by allowing network calls again.
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function testOnline(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.testOffline = testOffline;
|
|
4
|
-
exports.
|
|
4
|
+
exports.testOnline = testOnline;
|
|
5
5
|
const LOCAL_HOSTS = ['localhost', '127.0.0.1'];
|
|
6
6
|
const detectLeaks = process.argv.some(a => a.includes('detectLeaks'));
|
|
7
7
|
let mitm;
|
|
@@ -25,8 +25,8 @@ function testOffline() {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Undo/reset the
|
|
28
|
+
* Undo/reset the testOffline() function by allowing network calls again.
|
|
29
29
|
*/
|
|
30
|
-
function
|
|
30
|
+
function testOnline() {
|
|
31
31
|
mitm?.disable();
|
|
32
32
|
}
|