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

simut

v0.0.5

Published

To make super simple unit test on typescript.

Downloads

7

Readme

Simple-unit-test (simut)

To make super simple unit test on typescript.

Appendix

The idea was to make it as simple as possible to make some unit test in typescript or javascript. Was more thinking of using this for simple things like experiments where you need basic test to go faster or iterview tests, exercises like advent of code, etc

Tools like jest/tape are really complete and offer a lot but always require some setup (ts-node, babel, ...). I wanted something super easy to start with.

I usually use assert from node to do the tests but any testing library that throw on error should work.

To run the test i simple use esbuild-runner repo

esr tests/index.ts

Right now i only have one file, i'm looking into making this work for multiple files.

It's mostly a experiment and me trying to kill time while i'm looking for a job.

If you need production level testing, please use Jest, Mocha, Tape or your favorite battle tested test runner.

screnshot

Installation

yarn add simut

Peer dependencies

yarn add -D esbuild esbuild-runner

Usage/Examples

import fetch from 'node-fetch'
import { strict as assert } from 'assert'

import { test, run, group } from '../src'
import { lonelyNumber } from '../src/example'

group('Simple')

test('should return product', async () => assert.equal(lonelyNumber(1, 2, 3), 6, 'should return the product'))
test('should return the lonely number', async () => assert.equal(lonelyNumber(1, 1, 3), 3, 'should return the lonely number'))

group('Async')

test('should return the lonely number', async () =>
	new Promise((r, re) => {
		setTimeout(() => {
			try {
				assert.equal(lonelyNumber(1, 1, 4), 4, 'should return the lonely number')
				r()
			} catch (e) {
				re(e)
			}
		}, 1000)
	}))
test('should return product', async () => assert.equal(lonelyNumber(1, 2, 3), 6, 'should return the product'))

group('After Async')

test('should return 1', async () => assert.equal(lonelyNumber(3, 3, 3), 1, 'should return 1'))
test('should return the lonely number', async () => assert.equal(lonelyNumber(3, 1, 3), 1, 'should return the lonely number'))
test('should return the lonely number', async () => assert.equal(lonelyNumber(3, 1, 3), 3, 'should return the lonely number'))

group('Fetch first')

test('should return 1', async () =>
	fetch('https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1').then(() =>
		assert.equal(lonelyNumber(3, 3, 3), 1, 'should return 1')
	))

run()

API Reference

test

test('test name', async () => 'assertion returning a promise or throwing or error')

| Parameter | Type | Description | | :-------- | :--------- | :-------------------------------------------------------------------- | | title | string | Required. Description of the test | | fn | function | Required. function throwing of test error and returning a promise |

Create a new test

only

only('test name', async () => 'assertion returning a promise or throwing or error')

| Parameter | Type | Description | | :-------- | :--------- | :-------------------------------------------------------------------- | | title | string | Required. Description of the test | | fn | function | Required. function throwing of test error and returning a promise |

Create a new test and will filter all the other tests except the one using only.

useful if you want to focus on one test. Remember to switch back to test once you're done to run all of them again.

group

group('Group title')

| Parameter | Type | Description | | :-------- | :------- | :------------------------------ | | title | string | Required. Name of you group |

Create a group

run

run()

Run the tests and print the output in terminal

License

MIT