Workflow
Running Extension Tests
Extension Development Host model: second isolated instance launches to run tests with test Cocoon remote-controlling main UI.
Running Extension Tests
Explains the “Extension Development Host” model: a second, isolated instance of the application launches to run tests, with the test Cocoon instance remote-controlling the main UI.
The actual implementation details should be verified against Mountain/Source/Testing/ and Cocoon/Source/Services/Extension.ts.
Data Flow
Developer launches Mountain with --extensionDevelopmentPath
-> Extension activated in development mode
-> Developer runs "Run Tests" command (Ctrl+Shift+P)
-> Test Runner Service constructs special arguments:
--extensionDevelopmentPath
--extensionTestsPath
VSCODE_IPC_HOOK_CLI env var
-> Spawn new Mountain instance (Extension Development Host)
Test Host:
-> Detects --extension... flags, knows it is a test instance
-> Launches Cocoon sidecar with special env vars
-> Test Cocoon detects VSCODE_IPC_HOOK_CLI
-> Enters CLI test runner mode (no normal gRPC server)
-> Requires and executes script from --extensionTestsPath (e.g. mocha)
-> Mocha loads extension test files
Test Execution:
-> Tests call vscode.commands.executeCommand('my-extension.doSomething')
-> Lightweight test vscode shim intercepts require('vscode')
-> Shim connects to MAIN Mountain instance (not test instance)
-> gRPC: executeCommand sent to main Mountain
-> Main Mountain executes command, updates UI, returns result
-> Test proceeds: vscode.workspace.textDocuments[0]
-> Another gRPC call to main Mountain for document state
-> assert checks if main application state matches expected
Test Completion:
-> Mocha completes all tests, aggregates pass/fail counts
-> Prints results to stdout, exits with code (0/1)
-> Main Mountain's Test Runner Service monitored stdout
-> Parses results, displays notification: "10 passed, 0 failed"Phase 1: Test Discovery and Command Registration
- Extension under development includes a
testscript and contributes a command for its test runner. - Developer launches Mountain with
--extensionDevelopmentPath /path/to/my-extension. Extension activates in development mode.
Phase 2: Initiating the Test Run
- Developer executes “Run Tests” from the Command Palette in the main Mountain window.
- Test Runner Service prepares special arguments and environment variables for a new instance:
--extensionDevelopmentPath,--extensionTestsPath, andVSCODE_IPC_HOOK_CLI. - Spawns a new Mountain process — the “Extension Development Host”.
Phase 3: Test Execution in the Development Host
- New Mountain instance starts, sees the
--extension...flags, knows it is a test instance. - Launches its own Cocoon sidecar with special environment variables.
- Test Cocoon detects
VSCODE_IPC_HOOK_CLIand enters CLI test runner mode (no normal gRPC server, noinitExtensionHosthandshake). - Executes the test runner script from
--extensionTestsPath(typically mocha). - Test files execute. The
require('vscode')call is intercepted by a lightweightRequireInterceptorthat connects back to the main Mountain instance.
Phase 4: Remote Control and Result Reporting
- Test code calls
vscode.commands.executeCommand(...). Lightweight shim sends gRPC request to the original Mountain instance. - Main Mountain executes the command, UI updates, files open. Result returned to test Cocoon.
- Test proceeds to assertions (e.g. checking document state via another gRPC call to main Mountain).
- Mocha completes, aggregates results, prints to stdout, exits with code.
- Main Mountain’s Test Runner Service parses the output and displays a notification.
Key Source Files
Mountain/Source/Testing/— test runner serviceCocoon/Source/Services/Extension.ts— extension activation
