How to use the test-runner.Tom function in test-runner

To help you get started, we’ve selected a few test-runner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsdoc2md / jsdoc-to-markdown / test / cli.js View on Github external
const Tom = require('test-runner').Tom
const fs = require('fs')
const spawn = require('child_process').spawn
const a = require('assert')

const tom = module.exports = new Tom('cli')
const inputPath = 'test/fixture/ignore.js'

try {
  fs.mkdirSync('tmp-test')
} catch (err) {
  // dir exists
}

tom.test('cli: json option', function () {
  const outputFile = fs.openSync('tmp-test/ignore.json', 'w')
  return new Promise((resolve, reject) => {
    const handle = spawn(
      'node',
      ['bin/cli.js', '--no-usage-stats', '--no-cache', '--json', inputPath],
      { stdio: ['ignore', outputFile, 'ignore'] }
    )
github jsdoc2md / jsdoc-api / test / caching.js View on Github external
const Tom = require('test-runner').Tom
const jsdoc = require('../')
const Fixture = require('./lib/fixture')
const path = require('path')
const fs = require('fs-then-native')
const a = require('assert')

/* tests need to run sequentially as `jsdoc.cache` is shared between tests */
const tom = module.exports = new Tom('caching', { maxConcurrency: 1 })

tom.test('.explainSync({ files, cache: true })', async function () {
  const f = new Fixture('class-all')
  jsdoc.cache.dir = 'tmp/test/cache-sync'
  await jsdoc.cache.clear()
  const output = jsdoc.explainSync({ files: f.sourcePath, cache: true })
  const expectedOutput = f.getExpectedOutput(output)

  a.ok(typeof output === 'object')
  a.deepEqual(output, expectedOutput)
})

tom.test('.explain({ files, cache: true  })', async function () {
  const f = new Fixture('class-all')
  jsdoc.cache.dir = 'tmp/test/cache' + this.index
  await jsdoc.cache.clear()
github 75lb / typical / test-v10.js View on Github external
const Tom = require('test-runner').Tom
const t = require('./')
const a = require('assert')

const tom = module.exports = new Tom('typical-v10')

tom.test('.isIterable [v10]', function () {
  a.strictEqual(t.isIterable((async function * () {})()), true)
})
github 75lb / table-layout / test / bad-input.js View on Github external
const Tom = require('test-runner').Tom
const Table = require('../')
const a = require('assert')

const tom = module.exports = new Tom('bad-input')

tom.test('table.lines(): no data', function () {
  let table = new Table([])
  a.deepStrictEqual(table.getLines([]), [])

  table = new Table([])
  a.deepStrictEqual(table.getLines(), [])
})
github jsdoc2md / jsdoc-api / test / render-sync.js View on Github external
const Tom = require('test-runner').Tom
const jsdoc = require('../')
const Fixture = require('./lib/fixture')
const fs = require('fs')
const a = require('assert')

const tom = module.exports = new Tom('render-sync')

tom.test('.renderSync({ files })', function () {
  Fixture.createTmpFolder('tmp')
  Fixture.createTmpFolder('tmp/renderSync')
  const f = new Fixture('class-all')
  jsdoc.renderSync({ files: f.sourcePath, destination: 'tmp/renderSync/out' })
  a.doesNotThrow(function () {
    fs.statSync('./tmp/renderSync/out/index.html')
  })
})

tom.test('.renderSync({ source, destination })', function () {
  Fixture.createTmpFolder('tmp')
  Fixture.createTmpFolder('tmp/renderSync')
  const f = new Fixture('class-all')
  jsdoc.renderSync({ source: f.getSource(), destination: 'tmp/renderSync/out' })
github jsdoc2md / jsdoc-api / test / explain-sync.js View on Github external
const Tom = require('test-runner').Tom
const jsdoc = require('../')
const Fixture = require('./lib/fixture')
const path = require('path')
const a = require('assert')

const tom = module.exports = new Tom('explain-sync')

tom.test('.explainSync({ files })', function () {
  const f = new Fixture('class-all')
  const output = jsdoc.explainSync({ files: f.sourcePath })
  const expectedOutput = f.getExpectedOutput(output)

  a.ok(typeof output === 'object')
  a.deepStrictEqual(output, expectedOutput)
})

tom.test('.explainSync({ source })', function () {
  const f = new Fixture('class-all')
  const output = jsdoc.explainSync({ source: f.getSource() })
  const expectedOutput = f.getExpectedOutput(output)

  a.ok(typeof output === 'object')
github 75lb / renamer / test / internals / util-win32.js View on Github external
const util = require('../../lib/util')
const a = require('assert')
const os = require('os')
const Tom = require('test-runner').Tom

const tom = module.exports = new Tom('util-win32')

if (os.platform() === 'win32') {
  tom.test('util.depthFirstCompare(pathA, pathB) windows 1', function () {
    a.deepStrictEqual(util.depthFirstCompare('\\one\\two', '\\one'), -1)
    a.deepStrictEqual(util.depthFirstCompare('\\one', '\\one\\two'), 1)
    a.deepStrictEqual(util.depthFirstCompare('\\one', '\\one'), 0)
  })

  tom.test('util.depthFirstCompare(pathA, pathB) windows 2 (cygwin usage)', function () {
    a.deepStrictEqual(util.depthFirstCompare('/one/two', '/one'), -1)
    a.deepStrictEqual(util.depthFirstCompare('/one', '/one/two'), 1)
    a.deepStrictEqual(util.depthFirstCompare('/one', '/one'), 0)
  })
}
github lwsjs / lws / test / Lws-create.js View on Github external
const Tom = require('test-runner').Tom
const a = require('assert').strict
const Lws = require('../index')
const fetch = require('node-fetch')

const tom = module.exports = new Tom()

tom.test('one middleware', async function () {
  const port = 9400 + this.index
  class One {
    middleware (options) {
      return (ctx, next) => {
        ctx.body = 'one'
        next()
      }
    }
  }
  const lws = Lws.create({
    stack: [One],
    port: port
  })
  const response = await fetch(`http://127.0.0.1:${port}`)
github lwsjs / lws / test / lws-listen-https.js View on Github external
const Tom = require('test-runner').Tom
const Lws = require('../')
const a = require('assert').strict
const fetch = require('node-fetch')

const tom = module.exports = new Tom()

const https = require('https')
const agent = new https.Agent({
  rejectUnauthorized: false
})

tom.test('--https', async function () {
  const port = 9200 + this.index
  class One {
    middleware (options) {
      return (ctx, next) => {
        ctx.body = 'one'
        next()
      }
    }
  }
github lwsjs / lws / test / lws-listen-http.js View on Github external
const Tom = require('test-runner').Tom
const Lws = require('../')
const a = require('assert').strict
const fetch = require('node-fetch')

const tom = module.exports = new Tom()

tom.test('simple http', async function () {
  const port = 9100 + this.index
  class One {
    middleware (options) {
      return (ctx, next) => {
        ctx.body = 'one'
        next()
      }
    }
  }
  const lws = Lws.create({
    stack: [One],
    port: port
  })
  const response = await fetch(`http://127.0.0.1:${port}`)

test-runner

Fully-featured, lightweight command-line test runner

MIT
Latest version published 2 months ago

Package Health Score

60 / 100
Full package analysis

Popular test-runner functions