1.0.12 • Published 2 years ago

simple-mock-generator v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

How to use?

npm i simple-mock-generator
import { MockGenerator } from 'simple-mock-generator'

const gen = new MockGenerator();

const mockStringValue = gen.string();

When to use?

When you need to make nestJS test using jest, you need to make mock data.

But it sucks when you need to make mock data on your own like this!

const makeMockValues = (): Post => {
  const list = [];
  for (let i = 10; i < 60; i++) {
    list.push({
      id: i - 10,
      title: `the Test${i - 10}`,
      content: `the content of the Test${i - 10}`,
      createdAt: `2022-07-27T06:${i}:21.986Z`,
    });
  }
  return list;
};

If you use simple-mock-generator, you don’t need to do that.

The only thing you need to do is this!

const mockValue = gen.objectList(50, { object: new Post() });

Supports

  1. string
  2. number
  3. boolean
  4. date
  5. object
1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago