项目作者: dmail-old

项目描述 :
Control JavaScript execution for testing time dependent or async code
高级语言: JavaScript
项目地址: git://github.com/dmail-old/micmac.git
创建时间: 2017-09-11T07:29:20Z
项目社区:https://github.com/dmail-old/micmac

开源协议:

下载


micmac

npm
build
codecov

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

Example

  1. import { mockExecution } from "micmac"
  2. mockExecution(({ tick }) => {
  3. let called = false
  4. new Promise((resolve) => {
  5. setTimeout(resolve, 10)
  6. }).then(() => {
  7. called = true
  8. })
  9. // here called is false, no need to explain why
  10. tick(10)
  11. // here called is true thanks to tick(10) above, check documentation to understand why
  12. })

Check the API documentation

Install

npm i micmac