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.6.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 project and documentation are a work in progress.

test-object-model

Used for defining a test suite for use with a compatible runner. The model describes your test functions, how they are grouped, the order in which they should run, the config for each (timeout, max concurrency etc.)

It is supplied as input to a compatible runner, for example: test-runner, web-runner, esm-runner, mc-runner.

Synopsis

Trivial example creating a TOM containing two tests - one pass and one fail. Create a test by supplying a name and test function to tom.test. If the function throws or rejects the test is considered a fail.

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

tom.test('A successful test', function () {
  return 'This passed'
})

tom.test('A failing test', function () {
  throw new Error('This failed')
})

export default tom

Save the above to file named test.mjs, you can now run this test suite in several ways. For example, you can run it in Node.js by supplying it as input to esm-runner.

$ esm-runner tmp/synopsis.mjs

Start: 2 tests loaded

✓ synopsis A successful test [This passed]
⨯ synopsis A failing test

   Error: This failed
       at TestContext.<anonymous> (file:///Users/lloyd/Documents/test-runner-js/test-object-model/tmp/synopsis.mjs:10:9)
       ...
       at processTimers (internal/timers.js:475:7)


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

To confirm the test suite and the code under test is isomorphic you can run the same TOM in the browser (Chromium) using web-runner.

$ web-runner tmp/synopsis.mjs

Start: 2 tests loaded

✓ tom A successful test [This passed]
⨯ tom A failing test

   Error: This failed
       at TestContext.<anonymous> (http://localhost:7357/output.mjs:894:9)
       ...
       at http://localhost:7357/output.mjs:2016:21


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

API summary

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
})

Group.

tom.test('name')

Documentation


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

Keywords

FAQs

Package last updated on 07 Dec 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