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

test-object-model

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test-object-model

test-object-model

  • 0.5.0
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

view on npm npm module downloads Build Status Dependency Status js-standard-style

This documentation is a work in progress.

test-object-model

A TestObjectModel (TOM) instance is a tree structure containing a suite of tests. It is supplied as input to one of several runners:

Synopsis

Create a TOM instance and add a simple test. For the sake of simplicity, the follow example defines a trivial assert function but you can use any assertion library you like.

import Tom from 'test-object-model'
const tom = new Tom('Synopsis')

function assert(ok) {
  if (!ok) {
    throw new Error('Assertion error')
  }
}

tom.test('Quick maths', function () {
  const result = 2 + 2 - 1
  assert(result === 3)
})

export default tom

Save the above to file named test.mjs. You can now supply this as input to esm-runner.

$ esm-runner tmp/synopsis.mjs

Start: 1 tests loaded

 ✓ Synopsis Quick maths

Completed in 6ms. Pass: 1, fail: 0, skip: 0.

To confirm the code is isomorphic, you can test the same TOM in a headless browser instance (Chromium) using web-runner.

$ web-runner tmp/synopsis.mjs

Start: 1 tests loaded

 ✓ Synopsis Quick maths

Completed in 16ms. Pass: 1, fail: 0, skip: 0.

Usage basics

Supply a name and test function to tom.test. If the function throws or rejects the test is considered a fail.

tom.test('name', function () {
  // test
})

Skip a test.

tom.skip('name', function () {
  // test
})

Skip all but this and any other tests marked as only.

tom.only('name', function () {
  // test
})

Ignore a test.

tom.test('name')

Documentation


© 2018-19 Lloyd Brookes <75pound@gmail.com>.

FAQs

Package last updated on 15 Nov 2019

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