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

terst

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terst

A JavaScript testing component with a terse syntax.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

terst

A JavaScript testing component with a terse syntax. Supported in both Node.js and the browser.

Why?

Take a look at some of the popular JavaScript assertion/testing libraries, most of them are overly verbose.

examples from should.js docs:

var user = {
    name: 'tj'
  , pets: ['tobi', 'loki', 'jane', 'bandit']
};

user.should.have.property('name', 'tj');
user.should.have.property('pets').with.lengthOf(4);

or...

T (user.name)
EQ (user.name, 'tj')
EQ (user.pets.length, 4)

how about from expect.js:

expect(window.r).to.be(undefined);
expect(5).to.be.a('number');
expect([]).to.be.an('array');

or..

T (typeof window == 'undefined')
T (typeof 5 == 'number')
T (Array.isArray([]))

Don't even get me started on Node.js assert.

Terst has three main advantages:

  1. There are only five methods to remember. You aren't second guessing what each method really does or constantly referring to the documentation.
  2. Your eyes can quickly scan down the left side of your tests to quickly interpret what each test should do. Terst forces you to be very explicit.
  3. It's very light weight.

Install

Node.js/Browserify

npm install --save terst

Component

component install jprichardson/terst

Script

<script src="/path/to/terst.js"></script>

Methods

T (value, [msg])

Asserts if the value is truthy.

F (value, [msg])

Asserts if the value is falsey.

EQ (val1, val2, [msg])

Asserts if val1 strictly equals val2.

NEQ (val1, val2, [msg])

Asserts if val does not strictly equal val2.

APPROX (value, expected, delta, [msg])

Asserts if the value is within +- the delta.

NOTE: For descriptive errors, you can set terse.autoMsg = true. It's experimental only.

License

(MIT License)

Copyright 2013, JP Richardson jprichardson@gmail.com

Keywords

FAQs

Package last updated on 22 Oct 2013

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