28.1.0 • Published 4 months ago

@greenlabs/rescript-jest v28.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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!")
    })
  })
  
})
28.1.0

4 months ago

1.0.1

1 year ago

1.0.0

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago