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

@rockerjs/tsunit

v1.0.1

Published

decorator-based Test Tool

Downloads

5

Readme

基于decorator和mocha的单元测试框架

使用方式

  1. 安装npm包 npm install --save-dev @vdian/deco-mocha

  2. 通过npm script启动

{
     "scripts":{
         "test": "deco"
     }
}
  1. 写单测

在顶级目录创建一个test文件夹,在test文件中新建一个测试文件以*.spec.ts结尾. 开始写单测吧! 我们来完成一个简单的Hello world。

import  {contextConfiguration, Test, run, OnlyRun, Describe, before, after} from '@vdian/deco-mocha'
import * as chai from 'chai'
import * as path from 'path'

const expect = chai.expect

//contextConfiguration的参数为项目启动点的绝对路径
@contextConfiguration(path.resolve(__dirname,'../start'))
@Describe('测试Hello world')
class Helloworld {
    
    @Test('这是我的第一个测试')
    async firstTest(){
        console.log('Hello world');
        expect('Hello world').to.equal('Hello world');
    }
}

run(new Helloworld())

接下来运行npm test开始单元测试吧!

API DOCS

  • 基本API
    • run:运行测试实例
  • 装饰器
    • 类装饰器
      • contextConfiguration:参数为全局项目入口的绝对路径,用来注入项目环境
      • Describe:参数为此测试套件的描述,用来显示在报告中
    • 方法装饰器
      • Test:参数为此测试用例的描述,用来显示在报告中
      • before:所有测试用例之前执行一次函数
      • after:所有测试用例之后执行一次函数
      • beforeEach:每个测试用例执行之前都执行一次此函数
      • afterEach:每个测试用例执行之后都执行一次此函数
      • OnlyRun:此测试套件中仅执行此函数

TODO

-[] 更好的输出 -[] 支持流程控制decorator done -[] 更好的代码扩展性 done -[] 提交代码前的单测检验