fix(reporters): fix blob file name with label (#10346) · vitest-dev/vitest@c5e2e75 (original) (raw)

File tree

Original file line number Diff line number Diff line change
@@ -103,8 +103,8 @@ export class BlobReporter implements Reporter {
103 103 outputFile = [
104 104 'blob',
105 105 this.ctx.config.mergeReportsLabel,
106 -shard ? `-${shard.index}-${shard.count}` : '',
107 -].join('')
106 +shard ? `${shard.index}-${shard.count}` : '',
107 +].filter(Boolean).join('-')
108 108
109 109 outputFile = `${sanitizeFilePath(outputFile)}.json`
110 110
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import type { RunVitestConfig } from '#test-utils'
2 2 import type { File, Test } from '@vitest/runner/types'
3 3 import type { TestUserConfig, Vitest } from 'vitest/node'
4 4 import type { MergeReport } from 'vitest/src/node/reporters/blob.js'
5 -import { existsSync, rmSync } from 'node:fs'
5 +import { existsSync, readdirSync, rmSync } from 'node:fs'
6 6 import { mkdir, writeFile } from 'node:fs/promises'
7 7 import { buildTestTree, runVitest, useFS } from '#test-utils'
8 8 import { playwright } from '@vitest/browser-playwright'
@@ -652,10 +652,17 @@ test("macos only", () => {})
652 652 },
653 653 }
654 654 `)
655 +const blobDir = resolve(root, '.vitest/blob')
655 656 const result = await runVitest({
656 657 root,
657 -mergeReports: resolve(root, '.vitest/blob'),
658 +mergeReports: blobDir,
658 659 })
660 +expect(readdirSync(blobDir)).toMatchInlineSnapshot(`
661 + [
662 + "blob-linux.json",
663 + "blob-macos.json",
664 + ]
665 + `)
659 666 expect(trimReporterOutput(result.stdout)).toMatchInlineSnapshot(`
660 667 "✓ linux first.test.ts > always good
661 668 ✓ linux first.test.ts > works on linux