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

starfish

v0.1.1

Published

A javascript unit test code generator tool based on Mocha.js and Chai.js.

Downloads

2

Readme

Starfish(前端单元测试自动化工具)

===

命名由来

海星的最大特性是可再生可自行繁殖
希望测试工具也能够有这种特点:1.自动化 2.持续改进以便能够更好地自动化

功能特性

  1. 命令简洁,使用方便
  2. 分析源代码后,自动生成对应的测试代码框架(带有注释,上手没有难度)
  3. 测试框架使用客户端的mocha.js(BDD), 断言框架使用多兼容性的chai.js,更加语义化和人性化

安装说明

使用 npm 安装:

$ sudo npm install -g starfish

示例

假设某项目的根目录为 /project,所用到的js代码都在 /project/js 目录中,使用 starfish 举例如下:

$ sudo npm install -g starfish
$ cd /project
$ ut init
$ ut src js
$ ut -c
$ ut -r

使用帮助

starfish 提供的命令很方便:

查看帮助
$ ut -h (或者 --help)
初始化测试环境
$ ut init [path]
  1. init 命令是执行后续命令的必要前置条件,使用该命令时 [path] 参数如果不写则会将当前目录设置为测试环境的根目录

  2. 如果写了绝对路径会将该路径设置为测试环境的根目录,当前版本暂不支持相对路径,执行该命令后会给出提示使用 cd 命令切换到对应路径

  3. 命令执行完成后会在对应路径生成 tests 文件夹和一个.starfish文件,包含执行测试所需资源文件以及配置项

指定源代码目录名
$ ut src <src name>
  1. src 命令指定源代码目录名,默认的源代码目录为测试环境根目录(参见 初始化测试环境)下的“src“目录

  2. 如果您的javascript代码都存放在例如 “lib”或“source”目录中,则需要使用该命令进行修改

  3. 请务必要在您设置的测试环境根目录下执行该命令!

生成测试代码
$ ut -c [path]
  1. [path] 为选填(绝对路径),如果您执行参照之前的步骤已经切换到测试环境根目录下,建议不用输入 path

  2. 执行完该命令后会分析前一步指定的源代码目录下的所有javascript文件并在tests目录下生成测试文件

执行测试
$ ut -r [path]
  1. [path] 为选填(绝对路径),如果您执行参照之前的步骤已经切换到测试环境根目录下,建议不用输入 path

  2. 执行完该命令后会启动系统默认浏览器并显示测试页面

  3. 执行时页面会显示测试无法通过,这是由于生成的测试代码在目前版本中只分析了所有函数的输入值和返回值,因此您需要修改一下测试代码以通过单元测试

  4. 测试根目录/tests/resource/UTestRunner.html 是执行单元测试的页面,测试时所使用的脚本都已经引入,如果您的源代码脚本执行时还需要其他javascript脚本辅助,请手动将其引入该页面