Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(benchmark): table reporter for non TTY output #5484

Merged
merged 7 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add test
  • Loading branch information
hi-ogawa committed Apr 4, 2024
commit 9ecf0c663ca931f1f991c130d5d86e6acd7e532f
14 changes: 11 additions & 3 deletions test/benchmark/fixtures/basic/base.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,30 @@ describe('timeout', () => {
teardown() {

},
...benchOptions
})

bench('timeout75', async () => {
await timeout(75)
})
}, benchOptions)

bench('timeout50', async () => {
await timeout(50)
})
}, benchOptions)

bench('timeout25', async () => {
await timeout(25)
})
}, benchOptions)

// TODO: move to failed tests
// test('reduce', () => {
// expect(1 - 1).toBe(2)
// })
})

const benchOptions = {
time: 0,
iterations: 3,
warmupIterations: 0,
warmupTime: 0,
}
21 changes: 21 additions & 0 deletions test/benchmark/test/reporter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, it } from 'vitest'
import * as pathe from 'pathe'
import { runVitest } from '../../test-utils'

it('non-tty', async () => {
const root = pathe.join(import.meta.dirname, '../fixtures/basic')
const result = await runVitest({ root }, ['base.bench.ts'], 'benchmark')
const lines = result.stdout.split('\n').slice(3).slice(0, 10)
expect(lines).toMatchObject([
' ✓ base.bench.ts > sort',
' name',
' · normal',
' · reverse',
' ✓ base.bench.ts > timeout',
' name',
' · timeout100',
' · timeout75',
' · timeout50',
' · timeout25',
].map(s => expect.stringContaining(s)))
})
Loading