• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

acossta / captan / 17160634267

22 Aug 2025 04:28PM UTC coverage: 82.954% (+2.3%) from 80.673%
17160634267

Pull #24

github

web-flow
Merge df826cedd into 067376d50
Pull Request #24: feat: Complete CLI redesign with comprehensive testing

1206 of 1401 branches covered (86.08%)

Branch coverage included in aggregate %.

2469 of 3102 new or added lines in 16 files covered. (79.59%)

4 existing lines in 1 file now uncovered.

4595 of 5592 relevant lines covered (82.17%)

1625.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.0
/src/utils/test-utils.ts
1
/**
2
 * Test utility functions for consistent test setup
3
 */
4

5
import { vi, beforeEach, afterEach } from 'vitest';
2✔
6
import * as dateUtils from './date-utils.js';
2✔
7

8
/**
9
 * Set up fake timers and mock the current date
10
 * @param date - The date to freeze time at (defaults to 2024-01-01)
11
 */
12
export function setupFakeTimers(date: string = '2024-01-01') {
2✔
NEW
13
  beforeEach(() => {
×
14
    // Mock the date utility functions
NEW
15
    vi.spyOn(dateUtils, 'getCurrentDate').mockReturnValue(date);
×
NEW
16
    vi.spyOn(dateUtils, 'getCurrentTimestamp').mockReturnValue(`${date}T00:00:00.000Z`);
×
17

18
    // Also set system time for any direct Date usage
NEW
19
    vi.useFakeTimers();
×
NEW
20
    vi.setSystemTime(new Date(`${date}T00:00:00.000Z`));
×
NEW
21
  });
×
22

NEW
23
  afterEach(() => {
×
NEW
24
    vi.restoreAllMocks();
×
NEW
25
    vi.useRealTimers();
×
NEW
26
  });
×
NEW
27
}
×
28

29
/**
30
 * Standard mock cleanup for consistent test isolation
31
 */
32
export function setupMockCleanup() {
2✔
33
  afterEach(() => {
2✔
34
    vi.clearAllMocks();
78✔
35
  });
2✔
36
}
2✔
37

38
/**
39
 * Create a deterministic ID generator for tests
40
 * @param prefix - The prefix for generated IDs
41
 * @returns A function that generates sequential IDs
42
 */
43
export function createIdGenerator(prefix: string) {
2✔
NEW
44
  let counter = 0;
×
NEW
45
  return () => `${prefix}_test_${++counter}`;
×
NEW
46
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc