Socket
Socket
Sign inDemoInstall

@nestia/e2e

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestia/e2e

E2E test utilify functions


Version published
Weekly downloads
2.7K
decreased by-31.92%
Maintainers
1
Weekly downloads
 
Created
Source

Nestia E2E Helper

GitHub license npm version Downloads Build Status Guide Documents

Helper library for E2E testing in NestJS.

With @nestia/e2e, you can easily validate your NestJS server through E2E testing.

import {
    ArrayUtil,
    GaffComparator,
    RandomGenerator,
    TestValidator,
} from "@nestia/e2e";
import typia from "typia";

import api from "@samchon/bbs-api/lib/index";
import { IBbsArticle } from "@samchon/bbs-api/lib/structures/bbs/IBbsArticle";
import { IPage } from "@samchon/bbs-api/lib/structures/common/IPage";

export async function test_api_bbs_article_index_sort(
    connection: api.IConnection,
): Promise<void> {
    // GENERATE 100 ARTICLES
    const section: string = "general";
    const articles: IBbsArticle[] = await ArrayUtil.asyncRepeat(100, () =>
        api.functional.bbs.articles.store(connection, section, {
            writer: RandomGenerator.name(),
            title: RandomGenerator.paragraph(5)(),
            body: RandomGenerator.content(8)()(),
            format: "txt",
            files: [],
            password: RandomGenerator.alphabets(8),
        }),
    );
    typia.assertEquals(articles);

    // PREPARE VALIDATOR
    const validator = TestValidator.sort("BbsArticleProvider.index()")(
        async (
            sort: IPage.IRequest.Sort<IBbsArticle.IRequest.SortableColumns>,
        ) => {
            const page: IPage<IBbsArticle.ISummary> =
                await api.functional.bbs.articles.index(connection, section, {
                    limit: 100,
                    sort,
                });
            return typia.assertEquals(page).data;
        },
    );

    // DO VALIDATE
    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("+", false);
        await comp("-", false);
    }
}

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:

Keywords

FAQs

Package last updated on 03 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc