Nestia E2E Helper
Helper library for E2E testing in NestJS.
With @nestia/e2e
, you can easily validate your NestJS server through E2E testing.
import typia from "typia";
import {
ArrayUtil,
GaffComparator,
RandomGenerator,
TestValidator
} from "@nestia/e2e";
import api from "@samchon/bbs-api/lib/index";
import { IBbsArticle } from "@samchon/bbs-api/lib/structures/bbs/IBbsArticle";
export async function test_api_bbs_article_index_sort(
connection: api.IConnection,
): Promise<void> {
const section: string = "general";
const articles: IBbsArticle[] = await ArrayUtil.asyncRepeat(100, () =>
api.functional.bbs.articles.store(connection, section, {
writer: RandomGenerator.name(),
title: RandomGenerator.paragraph(),
body: RandomGenerator.content(),
format: "txt",
files: [],
password: RandomGenerator.alphabets(8),
}),
);
typia.assertEquals(articles);
const validator = validate_index_sort("BbsArticleProvider.idex()")(
(input: IBbsArticle.IRequest) =>
api.functional.bbs.articles.index(connection, section, input),
);
const components = [
validator("created_at")(GaffComparator.dates((x) => x.created_at)),
validator("updated_at")(GaffComparator.dates((x) => x.updated_at)),
validator("title")(GaffComparator.strings((x) => x.title)),
validator("writer")(GaffComparator.strings((x) => x.writer)),
validator(
"writer",
"title",
)(GaffComparator.strings((x) => [x.writer, x.title])),
];
for (const comp of components) {
await comp("+");
await comp("-");
}
}
Setup
npm install --save-dev @nestia/e2e
Just setup with npm command, that's all.
For referece, due to test program would not be published, I rcommend to install as dev
mode.
Features
About supported features, read descriptive comments of below: