Skip to main content
Home
This release is 2 versions behind 0.0.22 — the latest version of @alator21/jobless-machine. Jump to latest

Test framework

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
3 days ago (0.0.20)
class Assertion

Base class for all assertions in the test framework.

Assertions validate conditions during test execution and throw errors when validation fails. They can check context values, HTTP responses, or any other testable conditions.

Subclasses must implement:

  • type(): Return a string identifier for the assertion type
  • validate(): Perform the validation logic (throw on failure)

Examples

Example 1

class AgePositiveAssertion<Con> extends Assertion<Con> {
  constructor(private ageKey: string) {
    super();
  }

  type() { return "AgePositive"; }

  async validate(extractor: VExtractor<Con>) {
    const age = extractor.extractSpecificFromContext(this.ageKey);
    if (age <= 0) {
      throw new Error("Age must be positive");
    }
  }
}

Constructors

new
Assertion()

Type Parameters

Con extends Record<string, unknown>

Methods

abstract
type(): string

Get the type identifier for this assertion.

abstract
validate(extractor: VExtractor<Con>): Promise<void>

Perform the validation logic for this assertion.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@alator21/jobless-machine

Import symbol

import { Assertion } from "@alator21/jobless-machine";
or

Import directly with a jsr specifier

import { Assertion } from "jsr:@alator21/jobless-machine";

Add Package

pnpm i jsr:@alator21/jobless-machine
or (using pnpm 10.8 or older)
pnpm dlx jsr add @alator21/jobless-machine

Import symbol

import { Assertion } from "@alator21/jobless-machine";

Add Package

yarn add jsr:@alator21/jobless-machine
or (using Yarn 4.8 or older)
yarn dlx jsr add @alator21/jobless-machine

Import symbol

import { Assertion } from "@alator21/jobless-machine";

Add Package

vlt install jsr:@alator21/jobless-machine

Import symbol

import { Assertion } from "@alator21/jobless-machine";

Add Package

npx jsr add @alator21/jobless-machine

Import symbol

import { Assertion } from "@alator21/jobless-machine";

Add Package

bunx jsr add @alator21/jobless-machine

Import symbol

import { Assertion } from "@alator21/jobless-machine";