Skip to content

realar-project/jest

Repository files navigation

Realar Jest example

Example of easy unit testing with Realar.

import { mock } from "realar";
import { Notifier, Api, UserForm } from "./user-form";

test("User form should work", async () => {
  const notifierMock = mock(Notifier, {
    fail: jest.fn()
  });
  const apiMock = mock(Api, {
    userSave: jest.fn().mockResolvedValue(0)
  });

  const form = new UserForm("a", "b");

  await form.save();
  expect(notifierMock.fail).toHaveBeenCalled();
  expect(apiMock.userSave).toHaveBeenCalledWith("a", "b");
});

Installation

  git clone git@github.com:realar-project/realar-jest.git
  cd realar-jest
  npm run start

About

Realar Jest example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published