Skip to content

Testing: Set up test infrastructure and mocks #95

@fegge

Description

@fegge

Parent issue: #90

Overview

Set up the foundational test infrastructure before writing individual tests.

Tasks

  • Add devDependencies: jsdom, nyc, @vscode/test-electron
  • Create directory structure:
    test/
    ├── unit/
    ├── extension/
    ├── webview/
    ├── mocks/
    └── fixtures/
    
  • Create test/mocks/vscode.ts with factories:
    • createMockWorkspaceFolder(path)
    • createMockTextEditor(uri, selection?)
    • createMockExtensionContext()
  • Create test/fixtures/ with sample .weaudit files (valid, corrupt, empty, legacy)
  • Add npm scripts to package.json:
    "test": "npm run test:unit && npm run test:ext",
    "test:unit": "mocha -r ts-node/register test/unit/**/*.test.ts",
    "test:ext": "vscode-test",
    "coverage": "nyc npm run test:unit"
  • Configure nyc coverage thresholds (80% types.ts, 60% overall)

Acceptance Criteria

  • npm run test:unit executes successfully
  • Mock factories importable in tests
  • Fixtures available for subsequent test issues

Reference

See TESTING.md

Metadata

Metadata

Assignees

Labels

testingTest-related issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions