npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

miniprogram-simulate-extend

v0.1.0

Published

tools for miniprogram custom component unit test

Downloads

1

Readme

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