22 releases

new 0.1.8 Dec 7, 2024
0.1.7 Nov 30, 2024
0.1.1 Oct 30, 2024
0.1.0 May 23, 2024
0.0.1 May 23, 2024

#92 in Text editors

Download history 34/week @ 2024-08-17 1/week @ 2024-08-31 42/week @ 2024-09-14 11/week @ 2024-09-21 51/week @ 2024-09-28 128/week @ 2024-10-05 635/week @ 2024-10-12 206/week @ 2024-10-19 121/week @ 2024-10-26 17/week @ 2024-11-02 111/week @ 2024-11-09 548/week @ 2024-11-16 68/week @ 2024-11-23 200/week @ 2024-11-30

928 downloads per month
Used in testing-ls-adapter

MIT license

80KB
1.5K SLoC

Rust 1K SLoC // 0.0% comments Go 199 SLoC // 0.1% comments JavaScript 124 SLoC // 0.2% comments PHP 38 SLoC TypeScript 35 SLoC // 0.1% comments Just 4 SLoC

testing-language-server

⚠️ IMPORTANT NOTICE This project is under active development and may introduce breaking changes. If you encounter any issues, please make sure to update to the latest version before reporting bugs.

General purpose LSP server that integrate with testing. The language server is characterized by portability and extensibility.

Motivation

This LSP server is heavily influenced by the following tools

These tools are very useful and powerful. However, they depend on the execution environment, such as VSCode and Neovim, and the portability aspect was inconvenient for me. So, I designed this testing-language-server and its dedicated adapters for each test tool to be the middle layer to the parts that depend on each editor.

This design makes it easy to view diagnostics from tests in any editor. Environment-dependent features like neotest and VSCode's built-in testing tools can also be achieved with minimal code using testing-language-server.

Instllation

cargo install testing-language-server
cargo install testing-ls-adapter

Features

Configuration

Required settings for all editors

You need to prepare .testingls.toml. See this for an example of the configuration.

enableWorkspaceDiagnostics = true

[adapterCommand.cargo-test]
path = "testing-ls-adapter"
extra_arg = ["--test-kind=cargo-test"]
include = ["/**/src/**/*.rs"]
exclude = ["/**/target/**"]

[adapterCommand.cargo-nextest]
path = "testing-ls-adapter"
extra_arg = ["--test-kind=cargo-nextest"]
include = ["/**/src/**/*.rs"]
exclude = ["/**/target/**"]

[adapterCommand.jest]
path = "testing-ls-adapter"
extra_arg = ["--test-kind=jest"]
include = ["/jest/*.js"]
exclude = ["/jest/**/node_modules/**/*"]

[adapterCommand.vitest]
path = "testing-ls-adapter"
extra_arg = ["--test-kind=vitest"]
include = ["/vitest/*.test.ts", "/vitest/config/**/*.test.ts"]
exclude = ["/vitest/**/node_modules/**/*"]

[adapterCommand.deno]
path = "testing-ls-adapter"
extra_arg = ["--test-kind=deno"]
include = ["/deno/*.ts"]
exclude = []

[adapterCommand.go]
path = "testing-ls-adapter"
extra_arg = ["--test-kind=go-test"]
include = ["/**/*.go"]
exclude = []

[adapterCommand.node-test]
path = "testing-ls-adapter"
extra_arg = ["--test-kind=node-test"]
include = ["/node-test/*.test.js"]
exclude = []

[adapterCommand.phpunit]
path = "testing-ls-adapter"
extra_arg = ["--test-kind=phpunit"]
include = ["/**/*Test.php"]
exclude = ["/phpunit/vendor/**/*.php"]

VSCode

Install from VSCode Marketplace. You can see the example in settings.json.

coc.nvim

Install from :CocInstall coc-testing-ls. You can see the example in See more example

Neovim (nvim-lspconfig)

local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
local util = require "lspconfig/util"

configs.testing_ls = {
  default_config = {
    cmd = { "testing-language-server" },
    filetypes = {},
    root_dir = util.root_pattern(".testingls.toml", ".git" ),
  },
  docs = {
    description = [[
      https://github.com/kbwo/testing-language-server

      Language Server for real-time testing.
    ]],
  },
}

lspconfig.testing_ls.setup{}

Helix

See language.toml.

The array wrapper has been removed to simplify the configuration structure. Please update your settings accordingly.

Adapter

  • cargo test
  • cargo nextest
  • jest
  • deno test
  • go test
  • phpunit
  • vitest
  • node --test (Node Test Runner)

Writing custom adapter

⚠ The specification of adapter CLI is not stabilized yet.

See ADAPTER_SPEC.md and spec.rs.

Dependencies

~22–36MB
~609K SLoC