Skip to content

Add extension contract tests#3645

Open
zackverham wants to merge 2 commits intomainfrom
zverham/extension-api-contract-tests
Open

Add extension contract tests#3645
zackverham wants to merge 2 commits intomainfrom
zverham/extension-api-contract-tests

Conversation

@zackverham
Copy link
Collaborator

@zackverham zackverham commented Mar 3, 2026

Summary

  • Adds test/extension-contract-tests/ — a contract test suite that validates which VSCode and Positron APIs the extension calls, with what arguments, and what it expects back
  • Tests mock the vscode and positron modules, import actual extension source code against those mocks, and assert API interactions
  • Includes compile-time conformance checks (tsc) that verify mock properties exist in the real @types/vscode and Positron type definitions
  • No Go binary, no HTTP server, no network — tests run entirely in-process using Vitest with module aliasing
  • Adds just test-extension-contracts and just check-extension-contract-conformance recipes
  • Adds extension-contract-tests workflow to CI (pull request, main, nightly)

What's tested

Test File Extension Source APIs Validated
activation extension.ts activate() wiring: trust, URI handler, commands, contexts
auth-provider authProvider.ts authentication.registerAuthenticationProvider
connect-filesystem connect_content_fs.ts workspace.registerFileSystemProvider, FileSystemError
dialogs dialogs.ts window.showInformationMessage (modal), l10n.t
document-tracker entrypointTracker.ts Editor/document change events, commands.executeCommand("setContext")
extension-settings extension.ts workspace.getConfiguration("positPublisher")
file-watchers watchers.ts workspace.createFileSystemWatcher, RelativePattern
interpreter-discovery utils/vscode.ts commands.executeCommand, workspace.getConfiguration, Positron runtime
llm-tools llm/index.ts lm.registerTool
open-connect open_connect.ts window.showInputBox, workspace.updateWorkspaceFolders
positron-settings utils/positronSettings.ts workspace.getConfiguration("positron.r")
window-utils utils/window.ts window.showErrorMessage, withProgress, createTerminal

Test plan

  • just test-extension-contracts passes
  • just check-extension-contract-conformance passes
  • CI extension-contract-tests workflow passes

🤖 Generated with Claude Code

@zackverham zackverham requested a review from a team as a code owner March 3, 2026 21:45
@zackverham zackverham marked this pull request as draft March 4, 2026 15:51
Contract tests that validate which VSCode and Positron APIs the
extension calls, with what arguments, and what it expects back.
Tests mock the vscode and positron modules, import actual extension
code against those mocks, and assert API interactions.

Includes compile-time conformance checks that verify mock properties
exist in the real @types/vscode and positron type definitions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zackverham zackverham force-pushed the zverham/extension-api-contract-tests branch from 727db02 to 6cf3d08 Compare March 9, 2026 17:00
@zackverham zackverham changed the title Add extension API contract tests (extension-api-contracts) Add extension contract tests Mar 9, 2026
@zackverham zackverham marked this pull request as ready for review March 9, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant