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

triala

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

triala

A minimal test runner for programmers.

  • 0.4.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

Triala

A minimal test runner for programmers.

  • No globals.
  • No dependencies.
  • Asynchronous tests with ES6 await/async syntax.
  • Test cases are run sequentially in order.
  • And all that in less than 50 lines of code!

Writing tests

// my-fancy-suite.js

// Because globals are BAD.
import test from 'triala'

// Because there is no point in reinventing the wheel.
import assert from 'assert'

// Define your suite.
test('My fancy suite', class {
  // Define some standard hooks.
  async _before { console.log('I will be run before the suite.') }
  async _after { console.log('I will be run after the suite.') }
  async _beforeEach { console.log('I will be run before each test.') }
  async _afterEach () { console.log('I will be run after each test.') }

  // Prefix helper methods with '_'.
  async _timeout (ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
  }

  //
  // Define your tests.
  //

  'It should pass' () {
    assert.ok('Passing through')
  }

  'It should throw error' () {
    throw new Error('You shall not pass!')
  }

  async 'It should pass after some time' () {
    await this._timeout(1000)
    assert.ok('Passing through')
  }

  async 'It should fail after some time' () {
    await this._timeout(1000)
    assert.fail('You shall not pass!')
  }

  // Prefix with 'm ' (mute) to disable a test.
  // Prefix with 's ' (solo) to diable all other tests.
  // Prefixes are case insensitive. Multiple solos are supported.
  'm It will not be run' () {
    assert.fail('Does not matter.')
  }
})

Running tests

Just run the file:

node my-fancy-suite.js

For verbose mode:

node my-fancy-suite.js -v

Keywords

FAQs

Package last updated on 15 Mar 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