Skip to content

Commit 3506c38

Browse files
authored
Merge pull request #94 from ryoppippi/ryoppippi/vitest
feat: migrate test framework from bun:test to vitest
2 parents eb3fb1c + 2e5eb91 commit 3506c38

14 files changed

+354
-315
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- run: bun typecheck
1919
- name: Create default Claude directory for tests
2020
run: mkdir -p $HOME/.claude
21-
- run: bun test
21+
- run: bun run test
2222

2323
npm-publish-dry-run-and-upload-pkg-pr-now:
2424
runs-on: ubuntu-latest

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
**Testing and Quality:**
88

9-
- `bun test` - Run all tests
9+
- `bun run test` - Run all tests (using vitest)
1010
- Lint code using ESLint MCP server (available via Claude Code tools)
1111
- `bun run format` - Format code with ESLint (writes changes)
1212
- `bun typecheck` - Type check with TypeScript

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ cd ccusage
114114
bun install
115115

116116
# Run the tool
117-
bun run report [subcommand] [options]
117+
bun run start [subcommand] [options]
118118
```
119119

120120
## Usage

bun.lock

Lines changed: 184 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
"lint": "eslint --cache .",
3939
"prepack": "bun run build && clean-pkg-json",
4040
"prepare": "simple-git-hooks",
41-
"release": "bun lint && bun typecheck && bun test && bun run build && bumpp",
41+
"release": "bun lint && bun typecheck && vitest run && bun run build && bumpp",
4242
"start": "bun run ./src/index.ts",
43-
"test": "bun test",
43+
"test": "vitest run",
4444
"typecheck": "tsgo --noEmit"
4545
},
4646
"devDependencies": {
@@ -73,7 +73,11 @@
7373
"type-fest": "^4.41.0",
7474
"unplugin-macros": "^0.17.0",
7575
"unplugin-unused": "^0.5.1",
76-
"valibot": "^1.1.0"
76+
"valibot": "^1.1.0",
77+
"vitest": "^3.2.4"
78+
},
79+
"overrides": {
80+
"vite": "npm:rolldown-vite@latest"
7781
},
7882
"simple-git-hooks": {
7983
"pre-commit": "bun lint-staged"

src/calculate-cost.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import type { DailyUsage, SessionUsage } from './data-loader';
2-
import { describe, expect, test } from 'bun:test';
32
import {
43
calculateTotals,
54
createTotalsObject,
65
getTotalTokens,
76
} from './calculate-cost.ts';
87

9-
describe('Token aggregation utilities', () => {
10-
test('calculateTotals should aggregate daily usage data', () => {
8+
describe('token aggregation utilities', () => {
9+
it('calculateTotals should aggregate daily usage data', () => {
1110
const dailyData: DailyUsage[] = [
1211
{
1312
date: '2024-01-01',
@@ -39,7 +38,7 @@ describe('Token aggregation utilities', () => {
3938
expect(totals.totalCost).toBeCloseTo(0.03);
4039
});
4140

42-
test('calculateTotals should aggregate session usage data', () => {
41+
it('calculateTotals should aggregate session usage data', () => {
4342
const sessionData: SessionUsage[] = [
4443
{
4544
sessionId: 'session-1',
@@ -77,7 +76,7 @@ describe('Token aggregation utilities', () => {
7776
expect(totals.totalCost).toBeCloseTo(0.03);
7877
});
7978

80-
test('getTotalTokens should sum all token types', () => {
79+
it('getTotalTokens should sum all token types', () => {
8180
const tokens = {
8281
inputTokens: 100,
8382
outputTokens: 50,
@@ -89,7 +88,7 @@ describe('Token aggregation utilities', () => {
8988
expect(total).toBe(185);
9089
});
9190

92-
test('getTotalTokens should handle zero values', () => {
91+
it('getTotalTokens should handle zero values', () => {
9392
const tokens = {
9493
inputTokens: 0,
9594
outputTokens: 0,
@@ -101,7 +100,7 @@ describe('Token aggregation utilities', () => {
101100
expect(total).toBe(0);
102101
});
103102

104-
test('createTotalsObject should create complete totals object', () => {
103+
it('createTotalsObject should create complete totals object', () => {
105104
const totals = {
106105
inputTokens: 100,
107106
outputTokens: 50,
@@ -121,7 +120,7 @@ describe('Token aggregation utilities', () => {
121120
});
122121
});
123122

124-
test('calculateTotals should handle empty array', () => {
123+
it('calculateTotals should handle empty array', () => {
125124
const totals = calculateTotals([]);
126125
expect(totals).toEqual({
127126
inputTokens: 0,

src/data-loader-deduplication.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { describe, expect, it } from 'bun:test';
21
import { createFixture } from 'fs-fixture';
32
import {
43
createUniqueHash,

0 commit comments

Comments
 (0)