Skip to content
Skills Library
Programming · Testing

webda-testing

/webda-testing

Use when writing, running or fixing tests of a Webda app, its models, services or operations

Repository
webda.io ↗
Licence
LGPL
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

LGPL, otwarta.

What it does and when to use it

Use when writing, running or fixing tests of a Webda app, its models, services or operations

Original author description

Use when writing, running or fixing tests of a Webda app, its models, services or operations

How it works

  1. When to use
  2. Pattern
  3. Common mistakes
  4. Verify
  5. Reference
Original SKILL.md headings · 77 lines, 290 words
SKILL.md preview
---
name: webda-testing
description: Use when writing, running or fixing tests of a Webda app, its models, services or operations
---

# Testing a Webda app

## When to use

Adding tests for a model, a service or an operation, or fixing a failing test.

## Pattern

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`.

```ts
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");
  }
}
```

- Get models with `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`.
- By default the test replaces the `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).

## Common mistakes

```text
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
```

## Verify

`npm test`.

## Reference

https://docs.webda.io

Written for Webda 4.0.0-beta.

Versions

The database has no other skills named webda-testing.

Database snapshot: 13.11.2026 · package version 98200fef43a7 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100webda-configuration
    Use when changing webda.config.json, application parameters, the parameters of a service or the per-environment deployments of a Webda app
  • 100webda-services
    Use when adding or changing a Webda service, its parameters, its lifecycle or when wiring it in webda.config.json
  • 100mobiai-android-testing
    Use when writing or running tests in an Android project — unit tests, UI tests, choosing the right framework and patterns.
  • 100testing
    Use this skill when running or writing tests in the FAST monorepo — local test execution, CI workflows, Playwright fixtures, and WebUI integration testing.
  • 100mobiai-ios-testing
    Use when writing or running tests in an iOS project — unit tests, UI tests, snapshot tests, choosing the right framework.
  • 96load-testing
    Use when adding, changing or running a K6 scenario or a latency budget.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.