Skip to content

Commit 2950d9a

Browse files
committed
test: add automated testing framework with Vitest
Add comprehensive testing infrastructure: **Testing Framework:** - Add Vitest as test runner (fast, TypeScript-friendly, ESM support) - Add @vitest/coverage-v8 for code coverage reports - Add @vitest/ui for interactive test UI - Configure vitest.config.ts with proper paths and coverage settings **Unit Tests:** - Add tests/unit/linear-service-cycles.test.ts (14 tests) - Test getCycles(), getCycleById(), resolveCycleId() methods - Use mocks to avoid API calls - Verify PR czottmann#4 cycle methods work correctly **Integration Tests:** - Add tests/integration/cycles-cli.test.ts (8 tests) - Add tests/integration/project-milestones-cli.test.ts (5 tests) - Test end-to-end CLI functionality - Verify no "query too complex" errors (main bug fix) - Test all command flags and JSON output structure - Auto-skip if LINEAR_API_TOKEN not set **Command Coverage Tool:** - Add tests/command-coverage.ts for CLI-specific coverage analysis - Shows which commands have integration tests (more relevant than code coverage) - Automatically discovers new commands and tests - Reports: 35% of commands tested (cycles and project-milestones fully covered) **CI/CD:** - Add .github/workflows/ci.yml for automated testing - Run tests on every push and PR - Separate jobs for testing and linting - Optional integration tests if LINEAR_API_TOKEN secret configured **Scripts:** - pnpm test - Run all tests - pnpm test:watch - Run tests in watch mode - pnpm test:ui - Run tests with UI - pnpm test:coverage - Generate code coverage report - pnpm test:commands - Show command coverage report **Test Results:** - All 27 tests passing - Unit tests: 14 passed (instant, no API) - Integration tests: 13 passed (~15 seconds with API) - Command coverage: 35% (7/20 commands tested) - Cycles and project-milestones commands fully covered This establishes automated testing practices for the linearis project and prevents regressions in PR czottmann#4 fixes.
1 parent bb273d3 commit 2950d9a

File tree

8 files changed

+2449
-26
lines changed

8 files changed

+2449
-26
lines changed

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, pr-*]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test on Node ${{ matrix.node-version }}
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [22.x]
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 10.14.0
26+
27+
- name: Setup Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
cache: 'pnpm'
32+
33+
- name: Install dependencies
34+
run: pnpm install --frozen-lockfile
35+
36+
- name: Build project
37+
run: pnpm run build
38+
39+
- name: Run unit tests
40+
run: pnpm test
41+
42+
- name: Run integration tests (if API token available)
43+
if: env.LINEAR_API_TOKEN != ''
44+
env:
45+
LINEAR_API_TOKEN: ${{ secrets.LINEAR_API_TOKEN }}
46+
run: pnpm test
47+
48+
lint:
49+
name: Lint and Type Check
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- name: Checkout code
54+
uses: actions/checkout@v4
55+
56+
- name: Install pnpm
57+
uses: pnpm/action-setup@v4
58+
with:
59+
version: 10.14.0
60+
61+
- name: Setup Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: 22.x
65+
cache: 'pnpm'
66+
67+
- name: Install dependencies
68+
run: pnpm install --frozen-lockfile
69+
70+
- name: TypeScript type check
71+
run: pnpm run build
72+
73+
- name: Check for TypeScript errors
74+
run: pnpm exec tsc --noEmit

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
"build": "tsc && chmod +x dist/main.js",
1515
"clean": "rm -rf dist/",
1616
"start": "tsx src/main.ts",
17-
"test": "echo \"Error: no test specified\" && exit 1"
17+
"test": "vitest run",
18+
"test:watch": "vitest",
19+
"test:ui": "vitest --ui",
20+
"test:coverage": "vitest run --coverage",
21+
"test:commands": "tsx tests/command-coverage.ts"
1822
},
1923
"engines": {
2024
"node": ">=22.0.0"
@@ -28,14 +32,17 @@
2832
],
2933
"author": "Carlo Zottmann <[email protected]>",
3034
"license": "MIT",
31-
"packageManager": "pnpm@10.14.0",
35+
"packageManager": "pnpm@10.20.0",
3236
"dependencies": {
3337
"@linear/sdk": "^58.1.0",
3438
"commander": "^14.0.0"
3539
},
3640
"devDependencies": {
3741
"@types/node": "^22.0.0",
42+
"@vitest/coverage-v8": "^2.1.8",
43+
"@vitest/ui": "^2.1.8",
3844
"tsx": "^4.20.5",
39-
"typescript": "^5.0.0"
45+
"typescript": "^5.0.0",
46+
"vitest": "^2.1.8"
4047
}
4148
}

0 commit comments

Comments
 (0)