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

litests

v1.0.6

Published

A lightweight unit testing framework

Downloads

14

Readme

Litest - Lite lit tests (litests)

An extremely small unit testing library.

About

Litest is licensed under the MIT license and has been written by Lars Mueller alias LMD or appgurueu.

Features

  • Lightweight
  • Maintainable code
  • Good performance
  • Easy to use
  • Basic functionality

API

The API can read Lua 5.4 compatible Luon, but writes Lua 5.1 compatible Luon. Methods may raise errors for invalid objects (for instance functions) or invalid Luon.

Installation

Install the NPM package litests:

npm install litests

Import

const litest=require("litests");

Versions

  • 1.0.0
    • Initial version
  • 1.0.1
    • Documentation improvements & fixes
  • 1.0.2
    • Fixed links in package.json
  • 1.0.3
    • Removed unneeded dependency in package.json
  • 1.0.4
    • Fixed bug concerning object equality in ValueExpectation
  • 1.0.5
    • Fixed the fix
  • 1.0.6
    • Fixed objects referencing themselves

Expectations

Litest works using expectations - objects which verify whether given output is valid using expectation.isValid(out).

ValueExpectation
  • constructor(value): Creates an expectation
  • isValid(out): Returns whether the given out equals the value
AnyOfExpectation
  • constructor(values): Creates ValueExpectations for each value
  • isValid(out): Checks if any value matches out

Testers

Testers carry out test series and display total results.

Tester
  • constructor(func): create a Tester for a function
  • test(input, expectation): test whether a certain expectation is met
  • testAll(tests, expectation_constructor): test whether expectations are met for all tests
    • if an object is passed, input are keys & out are values
    • if an array is passed, all i-th values are input and all (i+1)-th ones are desired output
  • testEquals(input, value): shorthand for test(input, new ValueExpectation(value))
  • testEqualsAll(tests, value): also a shorthand - for testAll(tests, ValueExpectation)
  • passedTests(): how many tests have passed is displayed

BulkTester

  • constructor(func): create a BulkTester for a namespace/object containing multiple functions

Example

Luon uses Litest; below is an excerpt:

const litest = require("litests");
const luon = require("./index.js");

new litest.BulkTester(luon).testEqualsAll([
    "read",
    {
        "true": true,
        "false": false,
        "nil": undefined,
        "'\\226\\130\\172'": "€",
        "'\\xF0\\x90\\x8D\\x88'": "𐍈", // two character utf 16
        /* UTF-8 escape sequences to UTF-16 conversion */
        "{a=1}": {
            a: 1
        },
        "{[ [[yay]]]=true}": {
            yay: true
        },
        "{   much    =   'spacing'   }": {
            much: "spacing"
        }
    },
    "readRemoveComments", {
        "10--comment": 10,
        "10--[[comment]]0": 100,
    },
    "removeCommentsText",
    {
        "some--comment": "some",
        "some--[[multi-line comment]]": "some",
        "some--[===[multi-line comment]===]": "some",
    },
    "removeSpacingText",
    {
        "some tests": "sometests",
        "'some tests'": "'some tests'",
        "[===[some tests]===]": "[===[some tests]===]"
    },
    "writeText",
    [
        [true, false, true, undefined], "{true,false,true,nil}",
        "€", '"€"'
    ],
    "writeCompressedText",
    [
        "test'test", '"test\'test"'
    ],
    "writeBeautifiedText",
    [
        [true, false, true, undefined], "{\n  true,\n  false,\n  true,\n  nil\n}",
        [
            [1, 2],
            [3, 4]
        ], "{\n  {\n    1,\n    2\n  },\n  {\n    3,\n    4\n  }\n}"
    ]
]);