MCPcopy Index your code
hub / github.com/codeaashu/claude-code / testCostTracker

Function testCostTracker

scripts/test-services.ts:153–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

151}
152
153async function testCostTracker() {
154 console.log('\n--- Cost Tracking ---')
155 try {
156 const ct = await import('../src/cost-tracker.js')
157
158 // Total cost should start at 0
159 const cost = ct.getTotalCost()
160 if (cost === 0) {
161 pass('getTotalCost', 'starts at $0.00')
162 } else {
163 pass('getTotalCost', `current: $${cost.toFixed(4)} (non-zero means restored session)`)
164 }
165
166 // Duration should be available
167 const duration = ct.getTotalDuration()
168 pass('getTotalDuration', `${duration}ms`)
169
170 // Token counters should be available
171 const inputTokens = ct.getTotalInputTokens()
172 const outputTokens = ct.getTotalOutputTokens()
173 pass('Token counters', `input=${inputTokens}, output=${outputTokens}`)
174
175 // Lines changed
176 const added = ct.getTotalLinesAdded()
177 const removed = ct.getTotalLinesRemoved()
178 pass('Lines changed', `+${added} -${removed}`)
179 } catch (err: any) {
180 fail('Cost tracker', err.message)
181 }
182}
183
184async function testInit() {
185 console.log('\n--- Init (entrypoint) ---')

Callers 1

mainFunction · 0.85

Calls 2

passFunction · 0.85
failFunction · 0.85

Tested by

no test coverage detected