Skip to content

Commit 6029d83

Browse files
authored
Add unit tests with vitest (#15)
Vitest as a devDependency. New tests/ directory covers the four audit-identified pure-function targets: - duration.test.ts — formatDuration thresholds (ms/s/m/h), negatives, fractional clamp - pluralize.test.ts — 1 vs n, custom plurals, negatives - snapshotParser.test.ts — flat list, no-label rows, escaped-quote labels, depth from leading whitespace (spaces + tabs), ignored lines, dedupe, empty input, CRLF - scriptParser.test.ts — parseScript (blank/comment-only, context and env directives, action line numbers, comment stripping outside strings, escaped quotes inside quoted tokens, CRLF) + interpolate (basic, inside quotes, default fallback, defined beats default, missing → empty, non-vars untouched) + dequote (strip + unescape, unquoted passthrough, unbalanced quote) 35 specs total, ~130ms runtime. To make parseSnapshotRefs importable without VS Code at runtime, extracted it to src/runners/snapshotParser.ts (no vscode imports). src/services/snapshotIndex.ts re-exports it for existing callers. CI runs `npm test` between format:check and compile. package.json scripts: test (one-shot), test:watch. .vscodeignore excludes tests, .github, lint/format/test configs from the published vsix.
1 parent 430b997 commit 6029d83

10 files changed

Lines changed: 1641 additions & 98 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222

2323
- run: npm run format:check
2424

25+
- run: npm test
26+
2527
- run: npm run compile
2628

2729
- run: npm run package

.vscodeignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
.vscode/**
22
.vscode-test/**
33
src/**
4+
tests/**
5+
.github/**
6+
.oxlintrc.json
7+
.oxfmtrc.json
8+
vitest.config.ts
9+
examples/**
410
.gitignore
511
.gitattributes
612
.git/**

0 commit comments

Comments
 (0)