miniprogram-simulate
tools for miniprogram custom component unit test
Last updated 18 days ago by wechat-miniprogram .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install miniprogram-simulate 
SYNC missed versions from official npm registry.

miniprogram-simulate

介绍

小程序自定义组件测试工具集。

目前因为小程序独特的运行环境,所以对于小程序自定义组件的单元测试一直没有比较优雅的解决方案,此工具集就是为了解决此痛点而诞生的。将原本小程序自定义组件双线程分离运行的机制调整成单线程模拟运行,利用 dom 环境进行渲染,借此来完成整个自定义组件树的搭建。

运行此工具集需要依赖 js 运行环境和 dom 环境,因此可以采用 jsdom + nodejs(如 jest),也可以采用真实浏览器环境(如 karma)。文档使用简介中会提供简单的使用方式介绍。

安装

npm install --save-dev miniprogram-simulate

使用

const simulate = require('miniprogram-simulate')

test('test sth', () => {
    const id = simulate.load('/components/comp/index') // 加载自定义组件
    const comp = simulate.render(id) // 渲染自定义组件
    
    // 使用自定义组件封装实例 comp 对象来进行各种单元测试
})

以上只是一个简单的例子,实际上这个工具集必须搭配 jest 或 jsdom/mocha 等测试框架来使用,更为详细的使用细节请参阅下述文档:

协议

MIT

Current Tags

  • 1.2.8                                ...           latest (18 days ago)

38 Versions

  • 1.2.8                                ...           18 days ago
  • 1.2.7                                ...           5 months ago
  • 1.2.6                                ...           5 months ago
  • 1.2.5                                ...           6 months ago
  • 1.2.4                                ...           6 months ago
  • 1.2.3                                ...           6 months ago
  • 1.2.2                                ...           7 months ago
  • 1.2.1                                ...           7 months ago
  • 1.2.0                                ...           7 months ago
  • 1.1.6                                ...           8 months ago
  • 1.1.5                                ...           a year ago
  • 1.1.4                                ...           a year ago
  • 1.1.3                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.9                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.9                                ...           2 years ago
  • 0.1.8                                ...           2 years ago
  • 0.1.7                                ...           2 years ago
  • 0.1.6                                ...           2 years ago
  • 0.1.5                                ...           2 years ago
  • 0.1.4                                ...           2 years ago
  • 0.1.3                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 1
This Week 911
This Month 8,609
Last Day 429
Last Week 2,618
Last Month 6,826
Dependencies (5)
Dev Dependencies (19)

Copyright 2014 - 2016 © taobao.org |