Skip to main content

🌿 Test helper module for denops.vim

Works with
It is unknown whether this package works with Bun
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Browsers
JSR Score
94%
Published
2 weeks ago (2.0.1)

A Deno module designed for testing denops.vim. This module is intended to be used in the unit tests of denops plugins.

Note

If you want to test denops plugins with a real Vim and/or Neovim process, use the test function to define a test case, as shown below:

import {
  assert,
  assertEquals,
  assertFalse,
} from "jsr:@std/assert";
import { test } from "jsr:@denops/test";

test(
  "vim",
  "Start Vim to test denops features",
  async (denops) => {
    assertFalse(await denops.call("has", "nvim"));
  },
);

test({
  mode: "nvim",
  name: "Start Neovim to test denops features",
  fn: async (denops) => {
    assert(await denops.call("has", "nvim"));
  },
});

test({
  mode: "all",
  name: "Start Vim and Neovim to test denops features",
  fn: async (denops) => {
    assertEquals(await denops.call("abs", -4), 4);
  },
});

test({
  mode: "any",
  name: "Start Vim or Neovim to test denops features",
  fn: async (denops) => {
    assertEquals(await denops.call("abs", -4), 4);
  },
});

If you want to test denops plugins without a real Vim and/or Neovim process, use the DenopsStub class to create a stub instance of the Denops interface, as shown below:

import { assertEquals } from "jsr:@std/assert";
import { DenopsStub } from "jsr:@denops/test";

Deno.test("denops.call", async () => {
  const denops = new DenopsStub({
    call: (fn, ...args) => {
      return Promise.resolve([fn, ...args]);
    },
  });
  assertEquals(await denops.call("foo", "bar"), ["foo", "bar"]);
});
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @denops/test

Import symbol

import * as mod from "@denops/test";

Add Package

npx jsr add @denops/test

Import symbol

import * as mod from "@denops/test";

Add Package

yarn dlx jsr add @denops/test

Import symbol

import * as mod from "@denops/test";

Add Package

pnpm dlx jsr add @denops/test

Import symbol

import * as mod from "@denops/test";

Add Package

bunx jsr add @denops/test

Import symbol

import * as mod from "@denops/test";