test-object-model
test-object-model
Last updated 4 years ago by 75lb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install test-object-model 
SYNC missed versions from official npm registry.

view on npm npm module downloads Gihub repo dependents Gihub package dependents Build Status js-standard-style

test-object-model

This project and documentation are a work in progress.

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 or web-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 test-runner.

$ test-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.

const myGroup = tom.group('My group')

Before and after

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

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

Todo

tom.todo('name', function () {
  // Complete later
})

Reset a completed test, ready to run again.

tom.reset()

Documentation


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

Current Tags

  • 0.7.1                                ...           latest (4 years ago)

41 Versions

  • 0.7.1                                ...           4 years ago
  • 0.7.0                                ...           4 years ago
  • 0.6.1                                ...           5 years ago
  • 0.6.0                                ...           5 years ago
  • 0.5.10                                ...           5 years ago
  • 0.5.9                                ...           5 years ago
  • 0.5.8                                ...           5 years ago
  • 0.5.7                                ...           5 years ago
  • 0.5.6                                ...           5 years ago
  • 0.5.5                                ...           5 years ago
  • 0.5.4                                ...           5 years ago
  • 0.5.3                                ...           5 years ago
  • 0.5.2                                ...           5 years ago
  • 0.5.1                                ...           5 years ago
  • 0.5.0                                ...           5 years ago
  • 0.4.8                                ...           5 years ago
  • 0.4.7                                ...           5 years ago
  • 0.4.6                                ...           5 years ago
  • 0.4.5                                ...           5 years ago
  • 0.4.4                                ...           6 years ago
  • 0.4.3                                ...           6 years ago
  • 0.4.2                                ...           6 years ago
  • 0.4.1                                ...           6 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.8                                ...           6 years ago
  • 0.3.7                                ...           6 years ago
  • 0.3.6                                ...           6 years ago
  • 0.3.5                                ...           6 years ago
  • 0.3.4                                ...           6 years ago
  • 0.3.3                                ...           6 years ago
  • 0.3.2                                ...           6 years ago
  • 0.3.1                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.5                                ...           6 years ago
  • 0.2.4                                ...           6 years ago
  • 0.2.3                                ...           6 years ago
  • 0.2.2                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (8)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |