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 🙏

© 2026 – Pkg Stats / Ryan Hefner

testgen-ai

v1.0.9

Published

AI 驱动的智能测试生成工具

Readme

TestGen AI 🤖

一款基于 Node.js 的智能单元测试生成工具,支持通过自然语言交互快速生成完善的测试用例。


功能特性 ✨

  • 🚀 AI 智能生成:通过 OpenAI 模型自动生成测试代码
  • 🔄 检测更新:仅生成新增/修改方法的测试用例
  • 📁 配置管理:支持本地配置文件和环境变量
  • 多框架支持:支持 Jest/Mocha 测试框架
  • 💬 交互模式:提供友好的命令行交互界面

功能演示 🖥️

选择需要生成的JS或TS文件,例子:

// math.ts
export function getSizeImage(imgUrl: string, size: number):string {
    return `${imgUrl}?param=${size}x${size}`;
}

export function getCount(count: number):number | string {
    if (count < 0) return;
    if (count < 10000) {
        return count;
    } else if (Math.floor(count / 10000) < 10000) {
        return Math.floor(count / 1000) / 10 + "万";
    } else {
        return Math.floor(count / 10000000) / 10 + "亿";
    }
}

image.png

选择需要生成的方法

image.png

等待AI生成

image.png

生成成功

image.png

image.png

第二次生成,生成过的方法不会再出现

image.png

第二次生成,代码会自动合并

image.png


安装使用指南 📦

前置要求

  • Node.js v18+
  • npm 6+
  • 申请AI模型API-Key

安装方式

# 全局安装
npm install testgen-ai

使用方式

  1. 初始化,生成 testgen.config.json

    npx testgen -i
  2. 配置环境变量

    1. 访问https://bailian.console.aliyun.com/?spm=5176.29597918.J_SEsSjsNv72yRuRFS2VknO.2.53ef7ca0HZZ8we#/model-market
    2. 选取其中一个模型,打开 API调用示例 复制baseURL、apiKey、model到 testgen.config.json

    image.png

    image.png

  3. 运行项目,根据命令操作

    npx testgen

配置文件参数说明 📄

{
  "openai": {
    "apiKey": "",// api key
    "baseURL": "", // 请求url
    "model": "" // 模型
  },
  "config": {
    "cache": true, // 为true 代表缓存这次生成用例的方法,下次会略过
    "unit": "jest" // 单元测试框架
  }
}

程序流程图

image.png