Introduction
A mock library that lets you use decorators with classes to generate fake data. Based on @faker-js/faker。
class-mock
decorators essentially just stores metadata (configuration data) and does not modify the class.
Finally, when createMock(MockClass)
is executed, all metadata (configuration data) of MockClass
will be taken out, and then data generation will be performed with @faker-js/faker
.
Supports any ts
project or @babel/plugin-proposal-decorators (legacy
is true
) js
project.
Installation
npm i class-mock @faker-js/faker
yarn add class-mock @faker-js/faker
pnpm add class-mock @faker-js/faker
Notice
ts
project needs to be configured in tsconfig.json
:
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}