[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

chore: benchmark word error change (#5886)

authored by

Minseok Choi and committed by
GitHub
(Jun 16, 2024, 2:20 PM +0200) 84a4fdb4 8800601d

+8 -8
+2 -2
test/benchmark/test/basic.test.ts
··· 1 1 import fs from 'node:fs' 2 2 import { expect, it } from 'vitest' 3 3 import * as pathe from 'pathe' 4 - import type { FormattedBenchamrkReport } from 'vitest/src/node/reporters/benchmark/table/index.js' 4 + import type { FormattedBenchmarkReport } from 'vitest/src/node/reporters/benchmark/table/index.js' 5 5 import { runVitest } from '../../test-utils' 6 6 7 7 it('basic', { timeout: 60_000 }, async () => { ··· 17 17 expect(result.exitCode).toBe(0) 18 18 19 19 const benchResult = await fs.promises.readFile(benchFile, 'utf-8') 20 - const resultJson: FormattedBenchamrkReport = JSON.parse(benchResult) 20 + const resultJson: FormattedBenchmarkReport = JSON.parse(benchResult) 21 21 const names = resultJson.files.map(f => f.groups.map(g => [g.fullName, g.benchmarks.map(b => b.name)])) 22 22 expect(names).toMatchInlineSnapshot(` 23 23 [
+6 -6
packages/vitest/src/node/reporters/benchmark/table/index.ts
··· 30 30 if (this.ctx.config.benchmark?.compare) { 31 31 const compareFile = pathe.resolve(this.ctx.config.root, this.ctx.config.benchmark?.compare) 32 32 try { 33 - this.rendererOptions.compare = flattenFormattedBenchamrkReport( 33 + this.rendererOptions.compare = flattenFormattedBenchmarkReport( 34 34 JSON.parse( 35 35 await fs.promises.readFile(compareFile, 'utf-8'), 36 36 ), ··· 80 80 const outputDirectory = pathe.dirname(outputFile) 81 81 if (!fs.existsSync(outputDirectory)) 82 82 await fs.promises.mkdir(outputDirectory, { recursive: true }) 83 - const output = createFormattedBenchamrkReport(files) 83 + const output = createFormattedBenchmarkReport(files) 84 84 await fs.promises.writeFile(outputFile, JSON.stringify(output, null, 2)) 85 85 this.ctx.logger.log(`Benchmark report written to ${outputFile}`) 86 86 } ··· 109 109 } 110 110 } 111 111 112 - export interface FormattedBenchamrkReport { 112 + export interface FormattedBenchmarkReport { 113 113 files: { 114 114 filepath: string 115 115 groups: FormattedBenchmarkGroup[] ··· 132 132 median: number 133 133 } 134 134 135 - function createFormattedBenchamrkReport(files: File[]) { 136 - const report: FormattedBenchamrkReport = { files: [] } 135 + function createFormattedBenchmarkReport(files: File[]) { 136 + const report: FormattedBenchmarkReport = { files: [] } 137 137 for (const file of files) { 138 138 const groups: FormattedBenchmarkGroup[] = [] 139 139 for (const task of getTasks(file)) { ··· 169 169 return report 170 170 } 171 171 172 - function flattenFormattedBenchamrkReport(report: FormattedBenchamrkReport): FlatBenchmarkReport { 172 + function flattenFormattedBenchmarkReport(report: FormattedBenchmarkReport): FlatBenchmarkReport { 173 173 const flat: FlatBenchmarkReport = {} 174 174 for (const file of report.files) { 175 175 for (const group of file.groups) {