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

check-expect

v1.0.16

Published

check-expect is a simple unit testing framework for JavaScript development.

Downloads

5

Readme

check-expect

version

downloads

commitizen

mit

check-expect is a simple unit testing framework for JavaScript development in a JavaScript package. check-expect is a mature, viable way to make your test-driven development drive the design of your data, and your data drive the design of your functions. It's also a simple tool that allows you to execute unit tests inline with your code, in a systematic way.

This is a fork of the original check-expect, hosted on GitHub and last updated in 2016.

Features

  • [x] Support for inline unit tests. check-expect will support test created in another directory as well.
  • [x] Support for TDD and DDD development.
  • [x] Support for Systematic Program Design methods using HtDD and HtDF recipes.
  • [x] Support for color coded terminal (console) output.

TODO

  • [ ] GUI support.

Installation

  1. Install check-expect.

    
       npm install -g check-expect
    
  2. Now you can now add a reference to the check-expect package like so.

    
       // import package
       var checkExpect = require('check-expect');
    
  3. Write some code and test it using check-expect inline with your code.

    
       // import packages
       var checkExpect = require('check-expect');
          
       /* Usage and test modes
          checkExpect(function|object|type, mode, param, expected value, "a description of the test")
          
          checkExpect uses three Test Modes:
             - void_mode: for testing and designing algorithms with objects and primitive types
             - normal_mode: for testing and designing algorithms with primitive types
             - list_mode: for testing and designing algorithms with lists, objects and primitive types
          A test mode must be passed as the second argument to the checkExpect() function
       */
       var void_mode = 0;   
       var normal_mode = 1;
       var list_mode = 2;
    
       // define a function
       function square (a) {             // could replace return statement with
            return a * a;                // lambda statement: a => Math.pow(a,2)                        
       }                                 // from code_statement_B below.
    
       // examples
       var num_to_square = 12;
       var code_statement_A = 12 * 12;   // used in the function body
    
       // check the algorithm design of our square function, and unit test it at the same time
       checkExpect(square, normal_mode, 12, 144, "Square of a number");
    
       // Or just pass our examples
       checkExpect(square, normal_mode, num_to_square, code_statement_A, "Square of a number");
    
       // Or use lambda expressions
       var code_statement_B = a => Math.pow(a,2);
       checkExpect(square, normal_mode, num_to_square, code_statement_B(12), "Square of a number");
    
       // Or use JSON objects tested in void_mode
       var Person = {
          firstName:"John",
          lastName: "Doe",
          fullName: function () {
              return this.firstName + " " + this.lastName;
          }
       };
       checkExpect(Person.fullName(), void_mode, "void", "John Doe", "A test for fullnames");
          
       // Or use in testing functions that consume a list and produce a string
       var str1   = "Darel";
       var str2   = "Johnson";
       var param3 = [ "Darel", "Johnson"];
    
       function stringTogether (str1, str2){
           var newStr = "",
               str = [],
               numArgs = arguments.length;
           for(var i = 0; i < numArgs; i++){
               str = arguments[i];
               newStr += str +" ";
           }
           return newStr.trim();    
       }
       // should produce "Darel Johnson"
       checkExpect(stringTogether, normal_mode, param3, str1 +" "+ str2, "Concatenating strings");
    
    
  4. Execute your JavaScript from the command line (terminal) to see the unit test results. Most tests usually fail (RED) in the beginning.

  5. Refactor your code and execute your script until all functions under test, turn GREEN.

  6. That's it! You're done.

Upgrades

  1. Upgrade check-expect.

    
       npm update -g check-expect
    

That command will upgrade an existing installation of check-expect.

Configuration

None - No configuration needed.

Support

For check-expect support contact me at [email protected]

Project Issues

Report a bug at https://github.com/dareljohnson/check-expect/issues

License

This project originally started life as JavaScript unit test project. This project was abandoned in 2013 and was brought back to life as check-expect by our team in 2016. In the process, most of the project was refactored and brought up to speed with modern python best practices. The work done prior to the 2013 rewrite is licensed under MIT. Improvements since then are licensed under MIT. See LICENSE for more details.

SemVer

This project implements Semantic Versioning.

Credits