@naturalcycles/dev-lib 19.16.0 → 19.17.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.
@@ -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
+ }
@@ -16,3 +16,4 @@ export function defineVitestConfig(config?: Partial<ViteUserConfig>): ViteUserCo
16
16
  export const sharedConfig: InlineConfig
17
17
 
18
18
  export const CollectReporter: any
19
+ export const SummaryReporter: any
@@ -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()
@@ -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
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "19.16.0",
4
+ "version": "19.17.0",
5
5
  "dependencies": {
6
6
  "@biomejs/biome": "^2",
7
7
  "@commitlint/cli": "^19",