Socket
Socket
Sign inDemoInstall

triala

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    triala

A minimal test runner for programmers.


Version published
Weekly downloads
9
increased by350%
Maintainers
1
Install size
4.88 kB
Created
Weekly downloads
 

Readme

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

Last updated on 15 Mar 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc