Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@logicos/tinytest

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logicos/tinytest

Minimal testing framework

  • 0.4.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

@logicos/tinytest

Minimal testing framework

npm i -D @logicos/tinytest

or

yarn add -D @logicos/tinytest

Purpose

To test conditions, functions, and data structures in a simple and lightweight manner.

This package exposes testing tools for quick logic expectations to the more formal runSpec which allows for testing of sync and async functions simply.

@NOTE: truthy not required, just used as an example :)

How to use { test }

const { test } = require('@logicos/tinytest');
test(something(), somethingElse());

// --> Test has passed!
// or
// --> Test has failed!
test(something(), somethingElse(), 'Something check');

// --> Something check has passed!
// or
// --> Something check has failed!

How to use { runSpec }

const { runSpec } = require('@logicos/tinytest');

runSpec({
  name: 'Example of a pass',
  test: truthy.validate('foo', 'isFoo'),
  expect: true,
});
Example of a pass ✅
runSpec({
  name: 'Example of a fail',
  test: truthy.validate('foo', 'isBar'),
  expect: true,
});
Example of a fail ❌

RunSpec also works with Async

runSpec({
  name: 'Function that returns "foo" after some time',
  test: truthy.validate(eventuallyFoo(), 'isFoo'),
  expect: true,
});
Function that returns "foo" after some time ✅

How to use { btest }

btest only returns a boolean result of your test, no special messages.

btest(truthy.validate(2, 'isEven'), true);
btest(truthy.validate(2, 'isOdd'), true);
btest(truthy.validate(2, 'isOdd'), false);
true
false
true

FAQs

Package last updated on 18 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc