Skip to content

Latest commit

 

History

History

docs

README.md

vitest-gwt documentation

vitest-gwt is a thin Vitest binding over gwt-runner. It lets you write given-when-then style tests with strong typing and almost no ceremony.

import { describe } from "vitest";
import test from "vitest-gwt";

describe("a widget", () => {
  test("does the thing", {
    given: { a_widget },
    when: { the_thing_is_done },
    then: { the_thing_happened },
  });
});

Sections

Document Covers
Getting Started Install, version compatibility, your first test
Writing Tests The given/when/then definition, the Context (this), arrow-function rule, async, curried steps
Expecting Errors The expect_error clause
Scenarios Multi-step scenario flows with when/then/then_when
Shared Context withAspect / withTestOptions for setup, teardown, and per-suite Vitest options
API Reference Exports and signatures: test, withAspect, withTestOptions, TestContext

Why GWT?

Given-when-then forces you to split a test into three phases:

  • given — set up state
  • when — perform the action under test
  • then — assert the outcome

vitest-gwt runs every given first, then every when, then every then. Each test gets a fresh Context, and every clause is bound to that Context, so you read and write shared state through this instead of threading arguments.

Note

These docs are self-contained. They merge the gwt-runner core guide with the Vitest-specific details, so you do not need to jump to another repo for detailed usage.