test/context/index.js
/**
 * Initialise contexts for a test and run it.
 * @param {TestSuite} ts A test suite to run.
 * @param {string} name Name of the test in the test suite.
 */
Initialise contexts for a test and run it.
@param {TestSuite} ts A test suite to run.
@param {string} name Name of the test in the test suite.
Initialise contexts for a test and run it . @param { TestSuite } ts A test suite to run . @param { string } name Name of the test in the test suite .
async function runTest(ts, name) {
  if (!(name in ts)) throw new Error('No such test found')
  const contexts = Array.isArray(ts.context) ?
    ts.context : [ts.context].filter(c => c)
  const ic = await contexts.reduce(async (acc, Con) => {
    await acc
    const c = typeof Con == 'object' ? Con : new Con()
    if ('_init' in c) await c._init()
    return [...acc, c]
  }, [])
  const test = ts[name]
  await test(...ic)
}
async function runTest ( ts , name ) { if ( ! ( name in ts ) ) throw new Error ( 'No such test found' ) const contexts = Array . isArray ( ts . context ) ? ts . context : [ ts . context ] . filter ( c => c ) const ic = await contexts . reduce ( async ( acc , Con ) => { await acc const c = typeof Con == 'object' ? Con : new Con ( ) if ( '_init' in c ) await c . _init ( ) return [ ... acc , c ] } , [ ] ) const test = ts [ name ] await test ( ... ic ) }
Initialise contexts for a test and run it.
Initialise contexts for a test and run it .