@naturalcycles/dev-lib 16.0.1 → 16.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/dist/bin/dev-lib.js +4 -4
- package/dist/test.util.d.ts +2 -5
- package/dist/test.util.js +33 -6
- package/dist/testing/index.d.ts +1 -2
- package/dist/testing/index.js +1 -3
- package/package.json +3 -7
package/dist/bin/dev-lib.js
CHANGED
|
@@ -35,15 +35,15 @@ const commands = [
|
|
|
35
35
|
desc: 'Clean ./dist and ./dist-esm, then run "tsc" in CJS and ESM modes, with --emit and --noCheck',
|
|
36
36
|
},
|
|
37
37
|
new prompts_1.Separator(), // test
|
|
38
|
-
{ name: 'test', fn: test_util_1.
|
|
38
|
+
{ name: 'test', fn: test_util_1.runTest, desc: 'Run vitest/jest for *.test.ts files.' },
|
|
39
39
|
{
|
|
40
40
|
name: 'test-integration',
|
|
41
|
-
fn: () => (0, test_util_1.
|
|
41
|
+
fn: () => (0, test_util_1.runTest)({ integration: true }),
|
|
42
42
|
desc: 'Run jest for *.integration.test.ts files.',
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
name: 'test-leaks',
|
|
46
|
-
fn: () => (0, test_util_1.
|
|
46
|
+
fn: () => (0, test_util_1.runTest)({ leaks: true }),
|
|
47
47
|
desc: 'Run jest --detectLeaks for *.test.ts files.',
|
|
48
48
|
},
|
|
49
49
|
new prompts_1.Separator(), // lint
|
|
@@ -136,7 +136,7 @@ async function lbt() {
|
|
|
136
136
|
}
|
|
137
137
|
async function bt() {
|
|
138
138
|
await tscAll();
|
|
139
|
-
(0, test_util_1.
|
|
139
|
+
(0, test_util_1.runTest)();
|
|
140
140
|
}
|
|
141
141
|
async function tscAll() {
|
|
142
142
|
await (0, build_util_1.runTSCInFolders)(['.', 'scripts', 'e2e'], ['--noEmit']);
|
package/dist/test.util.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface RunTestOptions {
|
|
2
2
|
integration?: boolean;
|
|
3
3
|
manual?: boolean;
|
|
4
4
|
leaks?: boolean;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
* 1. Adds `--silent` if running all tests at once.
|
|
8
|
-
*/
|
|
9
|
-
export declare function runJest(opt?: RunJestOpt): void;
|
|
6
|
+
export declare function runTest(opt?: RunTestOptions): void;
|
|
10
7
|
export {};
|
package/dist/test.util.js
CHANGED
|
@@ -1,19 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.runTest = runTest;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
6
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
7
7
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
8
8
|
const paths_1 = require("./paths");
|
|
9
|
+
function runTest(opt = {}) {
|
|
10
|
+
if (nodeModuleExists('vitest')) {
|
|
11
|
+
runVitest(opt);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (nodeModuleExists('jest')) {
|
|
15
|
+
runJest(opt);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
console.log((0, nodejs_lib_1.dimGrey)(`vitest/jest not found, skipping tests`));
|
|
19
|
+
}
|
|
20
|
+
function runVitest(opt) {
|
|
21
|
+
const { integration, manual } = opt;
|
|
22
|
+
const processArgs = process.argv.slice(3);
|
|
23
|
+
const args = [...processArgs];
|
|
24
|
+
const { TZ = 'UTC', APP_ENV } = process.env;
|
|
25
|
+
const env = {
|
|
26
|
+
TZ,
|
|
27
|
+
};
|
|
28
|
+
if (!integration && !manual && !APP_ENV) {
|
|
29
|
+
Object.assign(env, {
|
|
30
|
+
APP_ENV: 'test',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
nodejs_lib_1.exec2.spawn('vitest', {
|
|
34
|
+
args: (0, js_lib_1._uniq)(args),
|
|
35
|
+
logFinish: false,
|
|
36
|
+
shell: false,
|
|
37
|
+
env,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
9
40
|
/**
|
|
10
41
|
* 1. Adds `--silent` if running all tests at once.
|
|
11
42
|
*/
|
|
12
|
-
function runJest(opt
|
|
13
|
-
if (!nodeModuleExists('jest')) {
|
|
14
|
-
console.log((0, nodejs_lib_1.dimGrey)(`node_modules/${(0, nodejs_lib_1.white)('jest')} not found, skipping tests`));
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
43
|
+
function runJest(opt) {
|
|
17
44
|
const { CI, CPU_LIMIT, TZ = 'UTC', APP_ENV, JEST_NO_ALPHABETIC, JEST_SHARDS } = process.env;
|
|
18
45
|
const cpuLimit = Number(CPU_LIMIT) || undefined;
|
|
19
46
|
const { integration, manual, leaks } = opt;
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { expectTypeOf } from 'expect-type';
|
|
2
1
|
import timekeeper from 'timekeeper';
|
|
3
2
|
export * from './mockAllKindsOfThings';
|
|
4
3
|
export * from './testing.util';
|
|
5
4
|
export * from './testOffline.util';
|
|
6
5
|
export * from './time.util';
|
|
7
|
-
export {
|
|
6
|
+
export { timekeeper };
|
package/dist/testing/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.timekeeper =
|
|
3
|
+
exports.timekeeper = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const expect_type_1 = require("expect-type");
|
|
6
|
-
Object.defineProperty(exports, "expectTypeOf", { enumerable: true, get: function () { return expect_type_1.expectTypeOf; } });
|
|
7
5
|
const timekeeper_1 = tslib_1.__importDefault(require("timekeeper"));
|
|
8
6
|
exports.timekeeper = timekeeper_1.default;
|
|
9
7
|
tslib_1.__exportStar(require("./mockAllKindsOfThings"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/dev-lib",
|
|
3
|
-
"version": "16.0
|
|
3
|
+
"version": "16.1.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky",
|
|
6
6
|
"tsn-debug": "tsn testScript.ts",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"eslint-plugin-simple-import-sort": "^12",
|
|
35
35
|
"eslint-plugin-unicorn": "^57",
|
|
36
36
|
"eslint-plugin-vue": "^10",
|
|
37
|
-
"expect-type": "^1",
|
|
38
37
|
"globals": "^16",
|
|
39
38
|
"husky": "^9",
|
|
40
39
|
"lint-staged": "^15",
|
|
@@ -48,13 +47,10 @@
|
|
|
48
47
|
"yargs": "^17"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"eslint-plugin-jest": "^28",
|
|
53
|
-
"jest": "^29",
|
|
54
|
-
"jest-junit": "^16",
|
|
50
|
+
"@vitest/coverage-v8": "^3",
|
|
55
51
|
"stylelint": "^16",
|
|
56
52
|
"stylelint-config-standard-scss": "^14",
|
|
57
|
-
"
|
|
53
|
+
"vitest": "^3"
|
|
58
54
|
},
|
|
59
55
|
"files": [
|
|
60
56
|
"dist",
|