Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@byndyusoft/dto-factory

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@byndyusoft/dto-factory

Factory to generate various DTO for unit tests

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

node-dto-factory

npm@latest test workflow code style: prettier semantic-release

Factory to generate various DTO for unit tests. Inspired by factory.ts.

Requirements

  • Node.js v12 LTS or later
  • npm or yarn

Install

npm install @byndyusoft/dto-factory

or

yarn add @byndyusoft/dto-factory

Usage

Example usage:

import { makeDtoFactory } from "@byndyusoft/dto-factory";
import { faker } from "@faker-js/faker";

class CharacterDto {
  public readonly id!: number;

  public readonly name!: string;
}

const characterDtoFactory = makeDtoFactory<CharacterDto>(() => ({
  id: faker.datatype.number(),
  name: faker.name.fullName(),
}));

// Build character without override
console.log(characterDtoFactory.build());

// Build character with override
console.log(
  characterDtoFactory.build({
    name: "Mage",
  }),
);

// Build characters without override
console.log(characterDtoFactory.buildList(10));

// Build characters with override
console.log(
  characterDtoFactory.buildList(10, {
    name: "Mage",
  }),
);

Maintainers

License

This repository is released under version 2.0 of the Apache License.

FAQs

Package last updated on 12 Sep 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