/webda:webda-testingfrom webda
Provides patterns for writing and fixing tests in Webda apps using vitest, @webda/test, and in-memory stores. Covers models, services, and operations.
Ships in webda. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Adding tests for a model, a service or an operation, or fixing a failing test.
Tests are vitest files in test/*.spec.ts, written as classes with @suite and @test from @webda/test. npm test builds first (pretest), because the app is loaded from lib/ and webda.module.json.
import { suite, test } from "@webda/test";
import * as assert from "node:assert";
import { resolve } from "node:path";
import { TestApplication, WebdaApplicationTest } from "@webda/core/lib/test/index.js";
import { useModel, useService } from "@webda/core";
const appDir = resolve(import.meta.dirname, "..");
class AppTestApplication extends TestApplication {
getNamespace() {
return "MyApp";
}
filterModule(_filename: string): boolean {
return true;
}
}
@suite
class NoteTest extends WebdaApplicationTest {
getTestConfiguration(): string {
return appDir;
}
getApplication() {
return new AppTestApplication(this.getTestConfiguration());
}
@test
async createsANote() {
const Note = useModel<any>("MyApp/Note");
const note = await Note.create({ text: "Hello", archived: false });
assert.strictEqual((await Note.ref(note.getUUID()).get()).text, "Hello");
}
@test
async callsAService() {
const greeting = (useService("GreetingService" as any) as any).greet("Ada");
assert.strictEqual(greeting, "Hello Ada");
}
}
useModel("<Namespace>/<Model>") and services with useService("<name>"): importing classes from src/ gives different class objects than the ones the app loaded from lib/.getNamespace() returns the webda.namespace of package.json.Registry store with an in-memory one. Override async tweakApp() {} to keep webda.config.json as is (then make assertions on data the test creates, since the store keeps data between runs).import { Note } from "../src/models/Note.model.js" → useModel("MyApp/Note")
Running vitest without building → npm test (runs webdac build first)
Assertions on global counts with a persistent store → assert on records created by the test
npm test.
Written for Webda 4.0.0-beta.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub loopingz/webda.io --plugin webda7 skills in this plugin
/webda-configurationUse when changing webda.config.json, application parameters, the parameters of a service or the per-environment deployments of a Webda app/webda-deployUse when deploying a Webda app, adding a deployment environment or building a container image or Lambda package/webda-modelsUse when adding or changing a Webda model, its fields, validation, primary key or relations to other models/webda-operationsUse when exposing behaviour to clients as an operation, or enabling REST, GraphQL, gRPC or MCP in a Webda app/webda-servicesUse when adding or changing a Webda service, its parameters, its lifecycle or when wiring it in webda.config.json/webda-storesUse when reading or writing model data, querying models, or choosing or switching the store (memory, file, MongoDB, PostgreSQL) of a Webda appOther plugins' skills for the same job