YAMLTest is a declarative testing framework for Node.js (requiring Node.js >=18.0.0) that enables defining HTTP, shell command, and Kubernetes resource tests entirely in YAML. It allows users to write test definitions without boilerplate, running them via CLI or a programmatic API. The package is currently at version 1.2.0 and, based on its active development and recent release, appears to follow a regular, though unspecified, release cadence for new features and fixes. Its core differentiator is the strict, schema-based validation of test definitions *before* execution, providing clear error messages and preventing malformed tests from running. It supports retries, environment variable interpolation, and can run tests locally or within Kubernetes pods, offering a robust solution for integration and end-to-end testing.
npm install yamltestVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to programmatically execute a simple HTTP GET test defined in a YAML string using the `runTests` function and log the overall outcome.
Always consult the official documentation for the exact YAML schema and property requirements for each test type (e.g., `http`, `command`, `wait`, `httpBodyComparison`). Pay close attention to error messages, which pinpoint the exact location of issues.
Ensure that every test definition YAML block contains only one primary key that corresponds to a test type. For instance, `http: { ... }` and `command: { ... }` cannot coexist within the same test object.Verify that your `http.method` field adheres strictly to one of the allowed values: GET, POST, PUT, DELETE, or PATCH.
Include a valid `source.selector` (e.g., `app: my-app`) when `source.type` is set to `pod` to specify which Kubernetes pods to interact with.
Change the `http.method` field to `GET`, `POST`, `PUT`, `DELETE`, or `PATCH`.
Review the YAML for Test #3 and ensure it contains exactly one top-level key corresponding to a single test type (e.g., `http:`, `command:`).
Add the `source.selector` field to Test #5, specifying the Kubernetes label selector to target the desired pod(s).
No dependency data recorded yet.