Skip to content

Control JavaScript execution for testing time dependent or async code

Notifications You must be signed in to change notification settings

dmail-old/micmac

Repository files navigation

micmac

npm build codecov

Mock most native way to execute JavaScript asynchonously to trigger them manually for testing.

Example

import { mockExecution } from "micmac"

mockExecution(({ tick }) => {
  let called = false
  new Promise((resolve) => {
    setTimeout(resolve, 10)
  }).then(() => {
    called = true
  })
  // here called is false, no need to explain why
  tick(10)
  // here called is true thanks to tick(10) above, check documentation to understand why
})

Check the API documentation

Install

npm i micmac