@naturalcycles/dev-lib 16.4.1 → 16.5.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.
@@ -7,6 +7,9 @@ const setupFiles = getSetupFiles(testType)
7
7
  const { include, exclude } = getIncludeAndExclude(testType)
8
8
  const isCI = !!process.env['CI']
9
9
  const junitReporterEnabled = isCI && testType !== 'manual'
10
+ const maxWorkers = getMaxWorkers()
11
+ const minWorkers = maxWorkers
12
+ const pool = 'threads' // threads are tested to be ~10% faster than forks in CI (and no change locally)
10
13
  process.env.TZ ||= 'UTC'
11
14
 
12
15
  if (testType === 'unit') {
@@ -17,12 +20,24 @@ if (silent) {
17
20
  process.env['TEST_SILENT'] = 'true'
18
21
  }
19
22
 
20
- console.log('shared vitest config', { testType, silent, isCI, runsInIDE, include, exclude })
23
+ console.log('shared vitest config', {
24
+ testType,
25
+ silent,
26
+ isCI,
27
+ runsInIDE,
28
+ include,
29
+ exclude,
30
+ pool,
31
+ maxWorkers,
32
+ })
21
33
 
22
34
  /**
23
35
  * Shared config for Vitest.
24
36
  */
25
37
  export const sharedConfig = {
38
+ pool,
39
+ minWorkers,
40
+ maxWorkers,
26
41
  watch: false,
27
42
  // dir: 'src',
28
43
  restoreMocks: true,
@@ -32,6 +47,11 @@ export const sharedConfig = {
32
47
  testTimeout: 60_000,
33
48
  sequence: {
34
49
  // todo: make it sort alphabetically
50
+ shuffle: {
51
+ files: true,
52
+ tests: false,
53
+ },
54
+ seed: 1, // this makes the order of tests deterministic (but still not alphabetic)
35
55
  },
36
56
  include,
37
57
  exclude,
@@ -49,7 +69,7 @@ export const sharedConfig = {
49
69
  outputFile: junitReporterEnabled ? `./tmp/jest/${testType}.xml` : undefined,
50
70
  coverage: {
51
71
  enabled: isCI && testType === 'unit',
52
- reporter: ['html', 'lcov', 'json', 'json-summary', !isCI && 'text'].filter(Boolean),
72
+ reporter: ['html', 'lcov', 'json', 'json-summary', !isCI && 'text'].filter(Boolean),
53
73
  include: ['src/**/*.{ts,tsx}'],
54
74
  exclude: [
55
75
  '**/__exclude/**',
@@ -147,3 +167,8 @@ function getIncludeAndExclude(testType) {
147
167
 
148
168
  return { include, exclude }
149
169
  }
170
+
171
+ function getMaxWorkers() {
172
+ const cpuLimit = Number(process.env['CPU_LIMIT'])
173
+ return cpuLimit || undefined
174
+ }
package/dist/test.util.js CHANGED
@@ -19,7 +19,6 @@ function runTest(opt = {}) {
19
19
  }
20
20
  function runVitest(opt) {
21
21
  const { integration, manual } = opt;
22
- const { CPU_LIMIT } = process.env;
23
22
  const processArgs = process.argv.slice(3);
24
23
  const args = [...processArgs];
25
24
  const env = {};
@@ -33,13 +32,6 @@ function runVitest(opt) {
33
32
  TEST_TYPE: 'manual',
34
33
  });
35
34
  }
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
- }
43
35
  nodejs_lib_1.exec2.spawn('vitest', {
44
36
  args: (0, js_lib_1._uniq)(args),
45
37
  logFinish: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "16.4.1",
3
+ "version": "16.5.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "tsn-debug": "tsn testScript.ts",