@naturalcycles/dev-lib 19.16.0 → 19.18.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/summaryReporter.js +26 -0
- package/cfg/vitest.config.d.ts +1 -0
- package/cfg/vitest.config.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { _ms } from '@naturalcycles/js-lib/datetime'
|
|
2
|
+
|
|
3
|
+
export class SummaryReporter {
|
|
4
|
+
constructor(cfg = {}) {
|
|
5
|
+
this.cfg = cfg
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
onTestRunEnd(testModules) {
|
|
9
|
+
const { count = 5 } = this.cfg
|
|
10
|
+
|
|
11
|
+
let stats = []
|
|
12
|
+
|
|
13
|
+
for (const mod of testModules) {
|
|
14
|
+
const name = mod.moduleId.split('/').at(-1)
|
|
15
|
+
const diag = mod.diagnostic()
|
|
16
|
+
stats.push({ name, ms: diag.duration })
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
stats = stats.sort((a, b) => b.ms - a.ms).slice(0, count)
|
|
20
|
+
|
|
21
|
+
console.log(' Slowest:')
|
|
22
|
+
stats.forEach(({ name, ms }) => {
|
|
23
|
+
console.log(String(_ms(ms)).padStart(10), name)
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
package/cfg/vitest.config.d.ts
CHANGED
package/cfg/vitest.config.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import { VitestAlphabeticSequencer } from './vitestAlphabeticSequencer.js'
|
|
3
3
|
import { defineConfig } from 'vitest/config'
|
|
4
|
+
import { SummaryReporter } from './summaryReporter.js'
|
|
5
|
+
export { SummaryReporter } from './summaryReporter.js'
|
|
4
6
|
export { CollectReporter } from './collectReporter.js'
|
|
5
7
|
|
|
6
8
|
const runsInIDE = doesItRunInIDE()
|
|
@@ -69,7 +71,7 @@ export const sharedConfig = {
|
|
|
69
71
|
pool,
|
|
70
72
|
minWorkers,
|
|
71
73
|
maxWorkers,
|
|
72
|
-
isolate:
|
|
74
|
+
isolate: false,
|
|
73
75
|
watch: false,
|
|
74
76
|
// dir: 'src',
|
|
75
77
|
restoreMocks: true,
|
|
@@ -90,6 +92,7 @@ export const sharedConfig = {
|
|
|
90
92
|
exclude,
|
|
91
93
|
reporters: [
|
|
92
94
|
'default',
|
|
95
|
+
new SummaryReporter(),
|
|
93
96
|
junitReporterEnabled && [
|
|
94
97
|
'junit',
|
|
95
98
|
{
|