# @volar/test-utils

> This module provides a simple way to start a language server and interact with it. It exports a function `startLanguageServer` which starts a language server and returns a handle to interact with it.

Latest version **2.4.31** (published 2026-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @volar/test-utils
pnpm add @volar/test-utils
yarn add @volar/test-utils
bun add @volar/test-utils
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.4.31 |
| Published | 2026-11-06 |
| First published | 2023-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1265 |
| Maintainers | johnsoncodehk |

## Links

- npm: https://www.npmjs.com/package/@volar/test-utils
- Repository: https://github.com/volarjs/volar.js
- Homepage: https://github.com/volarjs/volar.js#readme
- Issues: https://github.com/volarjs/volar.js/issues
- npm.io page: https://npm.io/package/@volar/test-utils

## Recent versions

- 2.4.31 (latest) — 2026-11-06
- 2.4.32-alpha.0 (next) — 2026-12-04
- 3.0.0-alpha.0 — 2026-10-29
- 2.4.30 — 2026-10-22
- 2.4.29 — 2026-10-22
- 2.4.28 — 2026-01-31
- 2.4.27 — 2025-12-10
- 2.4.26 — 2025-11-25
- 2.4.25 — 2025-11-25
- 2.4.24 — 2025-11-25
- 2.4.23 — 2025-08-08
- 2.4.22 — 2025-07-27
- 2.4.21 — 2025-07-27
- 2.4.20 — 2025-07-18
- 2.4.19 — 2025-07-15
- … 106 more at https://npm.io/package/@volar/test-utils/versions

## README

# @volar/test-utils

This module provides a simple way to start a language server and interact with it. It exports a function `startLanguageServer` which starts a language server and returns a handle to interact with it.

## Usage

First, import the module and start the language server:

```typescript
import { startLanguageServer } from '@volar/test-utils';

const serverHandle = startLanguageServer('path/to/server/module');
```

The `startLanguageServer` function takes the path to the server module as a string and optionally a current working directory as a string or URL.

The returned server handle provides several methods to interact with the language server:

- `initialize(rootUri: string, initializationOptions: InitializationOptions)`: Initializes the language server.
- `openTextDocument(fileName: string, languageId: string)`: Opens a text document.
- `openUntitledDocument(languageId: string, content: string)`: Opens an untitled text document.
- `closeTextDocument(uri: string)`: Closes a text document.
- Various `send*Request` methods: Send language-related requests to the server.

For example, to open a text document and send a completion request:

```typescript
await serverHandle.initialize('file:///path/to/workspace', {});
const document = await serverHandle.openTextDocument('path/to/file', 'typescript');
const completions = await serverHandle.sendCompletionRequest(document.uri, { line: 0, character: 0 });
```

---
_Source: https://npm.io/package/@volar/test-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
