@naturalcycles/dev-lib 16.2.0 → 16.2.2
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/init/vitest.config.mts +8 -0
- package/cfg/vitest.config.d.mts +3 -0
- package/cfg/{vitest.config.mts → vitest.config.mjs} +8 -11
- package/dist/test.util.js +1 -4
- package/dist/testing/testOffline.util.d.ts +2 -2
- package/dist/testing/testOffline.util.js +3 -3
- package/package.json +1 -1
- package/cfg/init/jest.config.js +0 -3
- package/cfg/init/jest.integration-test.config.js +0 -3
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
|
-
import type { InlineConfig } from 'vitest/node'
|
|
3
2
|
|
|
4
|
-
let silent
|
|
5
|
-
let testType
|
|
3
|
+
let silent
|
|
4
|
+
let testType = process.env['TEST_TYPE'] || 'unit'
|
|
6
5
|
|
|
7
6
|
const runsInIDE = process.argv.some(
|
|
8
7
|
a => a === '--runTestsByPath' || a.includes('IDEA') || a.includes('Visual Studio'),
|
|
@@ -27,7 +26,7 @@ if (testType === 'unit') {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
// Set 'setupFiles' only if setup files exist
|
|
30
|
-
const setupFiles
|
|
29
|
+
const setupFiles = []
|
|
31
30
|
if (fs.existsSync(`./src/test/setupVitest.ts`)) {
|
|
32
31
|
setupFiles.push('./src/test/setupVitest.ts')
|
|
33
32
|
}
|
|
@@ -35,8 +34,8 @@ if (fs.existsSync(`./src/test/setupVitest.${testType}.ts`)) {
|
|
|
35
34
|
setupFiles.push(`./src/test/setupVitest.${testType}.ts`)
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
let include
|
|
39
|
-
const exclude
|
|
37
|
+
let include
|
|
38
|
+
const exclude = ['**/__exclude/**']
|
|
40
39
|
|
|
41
40
|
if (testType === 'integration') {
|
|
42
41
|
include = ['{src,scripts}/**/*.integration.test.ts']
|
|
@@ -57,7 +56,7 @@ console.log('shared vitest config', { testType, silent, isCI, runsInIDE, include
|
|
|
57
56
|
/**
|
|
58
57
|
* Shared config for Vitest.
|
|
59
58
|
*/
|
|
60
|
-
export const sharedConfig
|
|
59
|
+
export const sharedConfig = {
|
|
61
60
|
watch: false,
|
|
62
61
|
// dir: 'src',
|
|
63
62
|
restoreMocks: true,
|
|
@@ -72,7 +71,7 @@ export const sharedConfig: InlineConfig = {
|
|
|
72
71
|
exclude,
|
|
73
72
|
coverage: {
|
|
74
73
|
enabled: isCI && testType === 'unit',
|
|
75
|
-
reporter: ['html', 'lcov', 'json', !isCI && 'text'].filter(Boolean)
|
|
74
|
+
reporter: ['html', 'lcov', 'json', !isCI && 'text'].filter(Boolean),
|
|
76
75
|
include: ['src/**/*.{ts,tsx}'],
|
|
77
76
|
exclude: [
|
|
78
77
|
'**/__exclude/**',
|
|
@@ -98,7 +97,7 @@ export const sharedConfig: InlineConfig = {
|
|
|
98
97
|
/**
|
|
99
98
|
* Detects if vitest is run with all tests, or with selected individual tests.
|
|
100
99
|
*/
|
|
101
|
-
function isRunningAllTests()
|
|
100
|
+
function isRunningAllTests() {
|
|
102
101
|
let vitestArg = false
|
|
103
102
|
let hasPositionalArgs = false
|
|
104
103
|
process.argv.forEach(a => {
|
|
@@ -115,5 +114,3 @@ function isRunningAllTests(): boolean {
|
|
|
115
114
|
|
|
116
115
|
return !hasPositionalArgs
|
|
117
116
|
}
|
|
118
|
-
|
|
119
|
-
type TestType = 'unit' | 'integration' | 'manual'
|
package/dist/test.util.js
CHANGED
|
@@ -21,10 +21,7 @@ function runVitest(opt) {
|
|
|
21
21
|
const { integration, manual } = opt;
|
|
22
22
|
const processArgs = process.argv.slice(3);
|
|
23
23
|
const args = [...processArgs];
|
|
24
|
-
const
|
|
25
|
-
const env = {
|
|
26
|
-
TZ,
|
|
27
|
-
};
|
|
24
|
+
const env = {};
|
|
28
25
|
if (integration) {
|
|
29
26
|
Object.assign(env, {
|
|
30
27
|
TEST_TYPE: 'integration',
|
|
@@ -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
|
}
|
package/package.json
CHANGED
package/cfg/init/jest.config.js
DELETED