Hoverfly — VS Code extensionLanguage support for Hoverfly JSON simulation files: diagnostics,
completion, and hover docs, powered by the The extension registers a dedicated Features
InstallFrom a packaged
|
| Setting | Type | Description |
|---|---|---|
hoverfly.registeredActions |
string[] |
Post-serve action names registered with your Hoverfly; used to complete/validate postServeAction. |
hoverfly.server.path |
string |
Absolute path to a hoverfly-lsp entry to launch (overrides workspace + bundled). Empty = auto. |
hoverfly.trace.server |
enum |
off | messages | verbose — trace the LSP traffic in the "Hoverfly LSP" output channel. |
hoverfly.registeredActions is delivered to the server via workspace/configuration (section
hoverfly) and as initializationOptions for clients that read config at startup.
Verification
All commands run from the repo root.
# 1. Install + build the server, then the extension (bundles + copies the server).
npm install
npm run build --workspace=hoverfly-lsp
npm run build --workspace=hoverfly-lsp-vscode
# Expect: editors/vscode/dist/extension.cjs and editors/vscode/server/{bin,dist}/ exist.
ls editors/vscode/dist/extension.cjs editors/vscode/server/bin/hoverfly-lsp.js editors/vscode/server/dist/cli.cjs
# 2. Unit-test the server-resolution logic.
npx vitest --run editors/vscode/test
# 3. Produce a .vsix (no Marketplace account needed).
npm run package --workspace=hoverfly-lsp-vscode
ls editors/vscode/*.vsix
Semantic highlighting
The server advertises an LSP semantic tokens provider, so VS Code colors the Hoverfly-specific
constructs a plain JSON grammar cannot see — chiefly the Handlebars template syntax inside templated
response body/header strings ({{ faker 'Name' }}, {{ Request.Path.[1] }}, {{#each …}}) and
matcher-name enums (exact, regex, jwt, …).
This works out of the box with no settings to flip:
- VS Code enables semantic highlighting by default (
editor.semanticHighlighting.enableddefaults to"configuredByTheme", and every built-in theme opts in). You only need to touch it if you previously set it tofalse. - The legend uses only standard LSP token types (
function,keyword,variable,property,enumMember,string,number,operator, …), which every shipped theme already colors — so no customeditor.tokenColorCustomizations/editor.semanticTokenColorCustomizationsare required. (You may still add them to taste.)
To confirm tokens are flowing, open a templated *.hoverfly.json, run Developer: Inspect Editor
Tokens and Scopes from the command palette, and click inside a {{ … }} — the "semantic token
type" line should read function on a helper name, operator on the {{, etc.
Manual QA checklist
The end-to-end editor behavior cannot be exercised headlessly; verify it by hand in a real VS Code window:
- Install the
.vsix(or launch the Extension Development Host with F5). - Open one of the repo fixtures (all paths relative to repo root):
testdata/valid/minimal.hoverfly.json— should show no diagnostics.testdata/valid/rich-stateful-templated.hoverfly.json— should show no errors; hover over a matcher name (e.g."glob") to see registry docs.testdata/invalid/hf4xx/dangling-states.hoverfly.json— should show squiggles forHF401/HF402/HF403dangling-state diagnostics.
- In a
*.hoverfly.jsonfile, type a matcher value{ "matcher": "" }and trigger completion inside the quotes — expect matcher names (exact,regex,jsonpath, …). - In a templated body (
"templated": true,"body": "{{ faker 'Name' }}"), confirm the template syntax is colored: the helper name (faker) reads as a function, the{{/}}as operators, and a known faker type ('Name') as an enum member (use Developer: Inspect Editor Tokens and Scopes to see the semantic token type). A plain.jsonshows no such coloring. - Confirm the bottom-right language indicator reads Hoverfly.
- Open an unrelated
.json(e.g.package.json) — expect no Hoverfly diagnostics and the normal JSON language mode. - Optional: set
"hoverfly.trace.server": "verbose"and check the Hoverfly LSP output channel for the LSP handshake.
To verify the hoverfly.server.path override or the workspace-node_modules path, point the
setting at a built packages/server/bin/hoverfly-lsp.js (or npm install @jterrazz/hoverfly-lsp
once it is published) and confirm the server still starts.