GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - wechat-miniprogram/miniprogram-simulate: 小程序自定义组件测试工具集

BranchesTags
Open more actions menu

Latest commit

 

History

189 Commits
189 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
src
src
 
 
test
test
 
 
.eslintrc.js
.eslintrc.js
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.js
build.js
 
 
index.d.ts
index.d.ts
 
 
index.js
index.js
 
 
jest-snapshot-plugin.js
jest-snapshot-plugin.js
 
 
karma.conf.js
karma.conf.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
webpack.config.js
webpack.config.js
 
 

Repository files navigation

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

About

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

Resources

Readme
MIT license
Activity
Custom properties

Stars

536 stars

Watchers

15 watching

Forks

65 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.