Skip to content

realar-project/jest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

fd43c15 · Jun 20, 2021

History

16 Commits
Dec 17, 2020
Feb 4, 2021
Dec 18, 2020
Jul 15, 2020
Jul 15, 2020
Jul 15, 2020
Jul 15, 2020
Dec 18, 2020
Jul 19, 2020
Jun 20, 2021
Jul 19, 2020
Jun 20, 2021

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 [email protected]: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