feat(PBI-49): add debugProps helper + Vitest test
Adds lib/debug.ts with debugProps(id, component, file) that returns data-debug-id and data-debug-label attrs in dev mode, empty object in production. Adds __tests__/lib/debug.test.ts covering both modes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ce43f7720a
commit
82b23a9c84
2 changed files with 40 additions and 0 deletions
24
__tests__/lib/debug.test.ts
Normal file
24
__tests__/lib/debug.test.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { describe, it, expect, vi } from 'vitest'
|
||||
|
||||
import { debugProps } from '@/lib/debug'
|
||||
|
||||
describe('debugProps', () => {
|
||||
it('returns both attrs with correct label in dev mode', () => {
|
||||
const result = debugProps('sprint-board', 'SprintBoard', 'components/sprint/sprint-board.tsx')
|
||||
expect(result).toEqual({
|
||||
'data-debug-id': 'sprint-board',
|
||||
'data-debug-label': 'SprintBoard — components/sprint/sprint-board.tsx',
|
||||
})
|
||||
})
|
||||
|
||||
it('returns empty object in production mode', () => {
|
||||
const original = process.env.NODE_ENV
|
||||
try {
|
||||
vi.stubEnv('NODE_ENV', 'production')
|
||||
const result = debugProps('sprint-board', 'SprintBoard', 'components/sprint/sprint-board.tsx')
|
||||
expect(result).toEqual({})
|
||||
} finally {
|
||||
vi.stubEnv('NODE_ENV', original ?? 'test')
|
||||
}
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue