Skip to content

Commit 864cfe9

Browse files
Nolin NaidooNolin Naidoo
authored andcommitted
fix: resolve lint errors - update biome ignore patterns
1 parent 30342ea commit 864cfe9

3 files changed

Lines changed: 240 additions & 2 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ Dates-LE is built for speed and efficiently processes files from 100KB to 10MB+.
153153
**Performance Monitoring**: Built-in real-time tracking with configurable thresholds
154154
**Full Metrics**: [docs/PERFORMANCE.md](docs/PERFORMANCE.md) • Test Environment: macOS, Bun 1.2.22, Node 22.x
155155

156+
For detailed information, see [Performance Monitoring](docs/PERFORMANCE.md).
157+
156158
<!-- PERFORMANCE_END -->
157159

158160
## 🔧 Troubleshooting
@@ -183,14 +185,20 @@ Absolutely! Extract timestamps from server logs, application traces, and monitor
183185
## 📊 Testing
184186

185187
**88 unit tests****90% function coverage, 86% line coverage**
186-
Powered by Vitest • Run with `bun test --coverage`
188+
Powered by Vitest • Run with `bun run test:coverage`
189+
190+
### Core Principle
191+
192+
**No broken or failed tests are allowed in commits.** All tests must pass before code can be committed or merged.
187193

188194
### Test Suite Highlights
189195

190196
- **48 error handling tests** with 100% coverage
191197
- **Comprehensive date format support** (ISO, RFC2822, Unix timestamps, custom formats)
192198
- **CSV, JSON, YAML, log file** extraction validation
193199

200+
For detailed testing guidelines, see [Testing Guidelines](docs/TESTING.md).
201+
194202
---
195203

196204
Copyright © 2025

biome.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"includes": ["src/**/*.ts", "!src/**/__performance__/**", "!src/**/__data__/**", "!src/**/__mocks__/**", "!src/**/sample/**", "!src/**/test-fixtures/**", "!src/**/*.bench.ts", "!src/**/*.bench.js", "!src/**/scripts/**"]
10+
"includes": [
11+
"src/**/*.ts",
12+
"!src/**/__performance__",
13+
"!src/**/__data__",
14+
"!src/**/__mocks__",
15+
"!src/**/sample",
16+
"!src/**/test-fixtures",
17+
"!src/**/*.bench.ts",
18+
"!src/**/*.bench.js",
19+
"!src/**/scripts"
20+
]
1121
},
1222
"formatter": {
1323
"enabled": true,

docs/TESTING.md

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# Dates-LE Testing Guidelines
2+
3+
This document outlines testing practices and policies for Dates-LE development.
4+
5+
## Core Principle
6+
7+
**No broken or failed tests are allowed in commits.**
8+
9+
All tests must pass before code can be committed or merged. This ensures code quality and prevents regressions.
10+
11+
## Running Tests
12+
13+
### Run All Tests
14+
15+
```bash
16+
bun run test
17+
```
18+
19+
### Run Tests with Coverage
20+
21+
```bash
22+
bun run test:coverage
23+
```
24+
25+
### Run Tests in Watch Mode
26+
27+
```bash
28+
bun run test:watch
29+
```
30+
31+
### Run Tests for Specific File
32+
33+
```bash
34+
bun x vitest run src/extraction/formats/json.test.ts
35+
```
36+
37+
## Test Structure
38+
39+
### Unit Tests
40+
41+
Located in `src/**/*.test.ts` and `src/**/*.spec.ts`:
42+
43+
- **Pure function tests** - Test extraction logic in isolation
44+
- **Format tests** - Test JSON, YAML, CSV, log file extraction
45+
- **Utility tests** - Test helper functions
46+
- **Configuration tests** - Test config validation
47+
48+
### Integration Tests
49+
50+
Located in `src/**/*.spec.ts`:
51+
52+
- **Sample file tests** - Test extraction against real file formats
53+
- **Cross-platform tests** - Ensure case-sensitivity compatibility
54+
- **End-to-end workflows** - Test complete command flows
55+
56+
## Test Coverage Requirements
57+
58+
- **Minimum Coverage**: Maintain reasonable coverage across core functionality
59+
- **Critical Paths**: All extraction logic must be tested
60+
- **Error Handling**: All error paths must be covered
61+
- **Edge Cases**: Boundary conditions must be tested
62+
63+
## Before Committing
64+
65+
### Checklist
66+
67+
- [ ] All tests pass (`bun run test`)
68+
- [ ] No broken tests
69+
- [ ] No skipped tests (unless intentionally)
70+
- [ ] Type checking passes (`bun x tsc -p ./`)
71+
- [ ] Linting passes (`bun run lint`)
72+
73+
### CI/CD Validation
74+
75+
The CI pipeline automatically:
76+
77+
1. Runs all tests on Ubuntu, macOS, and Windows
78+
2. Generates coverage reports
79+
3. Verifies all tests pass
80+
4. Fails the build if any tests fail
81+
82+
## Fixing Failed Tests
83+
84+
### When a Test Fails
85+
86+
1. **Don't commit the failure** - Fix the test or the code
87+
2. **Run locally first** - Verify fix works before pushing
88+
3. **Check all platforms** - Ensure fix works on Linux/Windows (case sensitivity, etc.)
89+
4. **Update test if needed** - If behavior changed intentionally, update test
90+
91+
### Common Issues
92+
93+
- **Case sensitivity** - Use exact case for file references (`README.md` not `readme.md`)
94+
- **Mock issues** - Ensure mocks are properly reset in `beforeEach`
95+
- **Timing issues** - Avoid `async/await` in tests when possible, use static imports
96+
97+
## Test Best Practices
98+
99+
### 1. Use Descriptive Test Names
100+
101+
```typescript
102+
// ✅ Good
103+
it('should extract ISO 8601 dates from JSON files', () => {
104+
// ...
105+
});
106+
107+
// ❌ Bad
108+
it('works', () => {
109+
// ...
110+
});
111+
```
112+
113+
### 2. Test One Thing Per Test
114+
115+
```typescript
116+
// ✅ Good - separate tests
117+
it('should extract ISO dates', () => { /* ... */ });
118+
it('should extract Unix timestamps', () => { /* ... */ });
119+
120+
// ❌ Bad - multiple concerns
121+
it('should extract ISO dates and Unix timestamps', () => { /* ... */ });
122+
```
123+
124+
### 3. Use Arrange-Act-Assert Pattern
125+
126+
```typescript
127+
it('should parse date from JSON', () => {
128+
// Arrange
129+
const json = '{"timestamp": "2025-01-15T10:30:00Z"}';
130+
131+
// Act
132+
const result = extractDates(json);
133+
134+
// Assert
135+
expect(result.dates).toContainEqual({
136+
value: '2025-01-15T10:30:00Z',
137+
format: 'ISO8601',
138+
});
139+
});
140+
```
141+
142+
### 4. Clean Up Mocks
143+
144+
```typescript
145+
beforeEach(() => {
146+
vi.clearAllMocks();
147+
// Reset mocks to default state
148+
});
149+
```
150+
151+
## Cross-Platform Testing
152+
153+
### Case Sensitivity
154+
155+
Always use exact case for file references:
156+
157+
```typescript
158+
// ✅ Good - works on all platforms
159+
const content = readSampleFile('README.md');
160+
161+
// ❌ Bad - fails on Linux
162+
const content = readSampleFile('readme.md');
163+
```
164+
165+
### Path Separators
166+
167+
Use platform-agnostic path handling:
168+
169+
```typescript
170+
import { join } from 'path';
171+
const filePath = join(SAMPLE_DIR, filename);
172+
```
173+
174+
## Coverage Reports
175+
176+
Coverage reports are generated automatically:
177+
178+
- **Location**: `coverage/index.html`
179+
- **Format**: HTML, LCOV, JSON
180+
- **CI/CD**: Coverage uploaded as artifact
181+
182+
## Continuous Integration
183+
184+
### GitHub Actions
185+
186+
Tests run automatically on:
187+
188+
- **Ubuntu** (latest)
189+
- **macOS** (latest)
190+
- **Windows** (latest)
191+
192+
All platforms must pass for the build to succeed.
193+
194+
### Pre-commit Hooks
195+
196+
Consider setting up pre-commit hooks to run tests before commits:
197+
198+
```bash
199+
# Install husky (if needed)
200+
bun add -d husky
201+
202+
# Add pre-commit hook
203+
echo "bun run test" > .husky/pre-commit
204+
```
205+
206+
## Reporting Test Issues
207+
208+
If you encounter test failures:
209+
210+
1. **Run locally** - Verify it fails consistently
211+
2. **Check CI logs** - See platform-specific errors
212+
3. **Reproduce** - Document steps to reproduce
213+
4. **Fix or report** - Either fix or create an issue
214+
215+
## Related Documentation
216+
217+
- [Performance Monitoring](PERFORMANCE.md) - Performance testing and benchmarks
218+
- [Architecture](ARCHITECTURE.md) - Code structure
219+
- [Commands](COMMANDS.md) - Command testing guidelines
220+

0 commit comments

Comments
 (0)