Testing System
Test Layers
┌──────────────────────────────────────────────────┐
│ Fixture Tests (string extraction integration) │ pnpm test:fixture
├──────────────────────────────────────────────────┤
│ E2E Tests (end-to-end in real VS Code) │ pnpm test:e2e
├──────────────────────────────────────────────────┤
│ Unit Tests (pure logic, no VS Code dependency) │ pnpm test:unit
└──────────────────────────────────────────────────┘Unit Tests (test/unit/)
pnpm test:unit # Run all unit tests
pnpm test:update # Run and update all snapshotsTech stack: ts-mocha + chai + chai-jest-snapshot
Since unit tests cannot depend on VS Code modules, you need to copy core logic into test files and use mock variables. See test/unit/translators/editorLLM.test.ts for the pattern.
test/unit/
├── setup.ts # Test initialization
├── commands/ # Command tests
├── utils/ # Utility function tests
│ ├── NodeHelper.test.ts # splitKeypath, getPathWithoutNamespace
│ ├── Regex.test.ts # findCallExpressionStart/End
│ ├── flat.test.ts # flatten / unflatten
│ └── pathMatching.test.ts # Path matching
├── extraction/ # String extraction detection tests
└── translators/ # Translation engine testsE2E Tests (test/e2e/)
pnpm test:e2e # Run E2E tests
pnpm test:e2e:update # Run and update all snapshotsUses @vscode/test-electron to launch a real VS Code instance, loads example projects from examples/by-frameworks/ as workspace, and verifies framework detection, key parsing, coverage.
Snapshot files record coverage reports (allKeys, translatedKeys) and key detection results (getKeys() output).
WARNING
E2E test fixtures come from examples/by-frameworks/. Modifying example projects will affect E2E test results.
Fixture Tests (test/fixtures/)
pnpm test:fixtureCopies test/fixtures/{framework}/{category}/{name}/input/ to a temp directory, opens in real VS Code, executes extract-hard-strings-batch, and compares results with output/.
WARNING
Fixture tests only run reliably in GitHub Actions. Locally, they may fail or get interrupted due to VS Code instance startup timing and resource contention issues. To verify extraction functionality, push to CI.
Best Practices
- After modifying core logic →
pnpm test:unit(fast feedback) - After modifying key parsing →
pnpm test:e2e(full framework verification) - After modifying extraction → Push to CI to run
pnpm test:fixture(unreliable locally) - Before packaging →
pnpm test:unit && pnpm vsce:pack - Final verification → Install vsix in real project, test navigation and inline display
