Skip to content

kawokas/tomock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
}

About

Build mock object by type definition

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published