sequelize-mocks
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

sequelize-mocks

Generate sequelize models based on sequelize-typescript annotations

Example

import { mockModel } from 'sequelize-mocks';
import { Functionality } from './functionality';
import MyModel from './my.model';

describe('Some Functionality', () => {
  let functionality;

  beforeEach(() => {
    functionality = new Functionality();
  });

  test('your test', async () => {
    // create a new instance of MyModel with all properties filled
    const model = mockModel(MyModel);
    await model.save();

    const result = await functionality.someMethod(model);

    expect(result).toEqual('your result');
  });

  test('custom values', async () => {
    // you can also override the generated values for each property
    const model = mockModel(MyModel, { myField: false });
    await model.save();

    const result = await functionality.someMethod(model);

    expect(result).toEqual('your result');
  });
});

Dependencies (1)

Dev Dependencies (17)

Package Sidebar

Install

npm i sequelize-mocks

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

7.85 kB

Total Files

5

Last publish

Collaborators

  • maxjoehnk