Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 645 Bytes

README.md

File metadata and controls

41 lines (34 loc) · 645 Bytes

tomock

Tomock is mocker functions generator from type definitions

example

yarn install
yarn run build
yarn run tomock-generate @types/** ./out

in (@types/index.d.ts)

interface Hoge {
  hoge: string
  /** default: random */
  flg: boolean
  /** default: 45 */
  num: number
}

run command

yarn run tomock-generate @types/** ./out

out

export const makeHogeMock = (
    payload: { [key in keyof Hoge]?: Hoge[key] } = {}
  ): Hoge => {
  return Object.assign({}, {
      hoge: 'this is mock string',
      flg: (Math.random() < 0.5),
      num: 45
    }, payload)
}