@greenlabs/rescript-jest

28.1.0 • Public • Published

rescript-jest

Install

npm i @greenlabs/rescript-jest --dev
or
yarn add @greenlabs/rescript-jest --dev
"bs-dev-dependencies": [
  "@greenlabs/rescript-jest"
]

Usage

open Jest
open Expect

describe("Test my module", () => {
  let myMockFunction = JestJs.make2((msg, msg2) => msg ++ msg2)
  let setup = () => {
    (myMockFunction->Mock.fn)("Hello ", "world!")
  }
  describe("When call setup", () => {
    beforeEach(() => {
      setup()
    })

    afterEach(() => {
      myMockFunction->Mock.mockClear
    })

    test("myFunction is should called", () => {
      expect(myMockFunction)->toBeCalled()
      expect(myMockFunction)->toBeCalledTimes(1)
    })

    test("myFunction is should called with 'Hello ', 'world!'", () => {
      expect(myMockFunction)->toBeCalledWith(("Hello ", "world!"))
    })

    test("myFunction return is 'Hello world!'", () => {
      expect(myMockFunction)->toReturnedWith("Hello world!")
    })
  })
  
})

Readme

Keywords

Package Sidebar

Install

npm i @greenlabs/rescript-jest

Weekly Downloads

22

Version

28.1.0

License

MIT

Unpacked Size

31.1 kB

Total Files

7

Last publish

Collaborators

  • minukang
  • gyeop
  • miryangjung
  • jaeholee.gl
  • namenu
  • moondaddi
  • yousleepwhen
  • kimchhickey