🐶
blog.terrier.dev

posted: 2019/03/24

JestでreadFileSyncをmockするワンライナー


雑に最短でやる場合のを見つけたのでメモ。
jest.mock("fs") // これは必要

const content = "some text"
jest.spyOn(require("fs"), "readFileSync").mockReturnValue(content)

Edit on Github
@terrierscript