@pdnsyamkumar/test-utils
v1.0.2
Published
Framework-agnostic test data and assertion utilities.
Readme
@pdnsyamkumar/test-utils
Framework-agnostic testing utilities and data generators. This package can be used alongside Playwright, Jest, Cypress, or any other JavaScript testing framework.
BaseTestData
A powerful utility designed to manage default test payloads and effortlessly modify them on the fly using override, exclude, and only arguments.
Example
import { BaseTestData } from "@pdnsyamkumar/test-utils";
const testData = new BaseTestData();
const defaults = {
name: "Syam",
preferences: { theme: "dark", notifications: true },
};
// Override specific fields
const updated = testData.getTestData(defaults, {
override: { name: "Pdn" },
});
// Exclude nested dot paths
const minimal = testData.getTestData(defaults, {
exclude: ["preferences.notifications"],
});override accepts DeepPartial<T>, so nested values can be changed without
repeating sibling fields. exclude and only accept top-level keys or nested
dot paths (including array indices). Use either exclude or only, not both.
getTestData returns Partial<T>. When selecting or removing a nested path,
the returned nested object can be incomplete at runtime; access those nested
values defensively.
