src/lib/stream.js
/**
 * Assigns test suite stack to each data object. Maintains a
 * test suite stack, and if a notification with type
 * 'test-suite-start' is coming, the name of the test suite
 * is pushed onto the stack. When 'test-suite-end' notification
 * comes, the top item is popped from the stack.
 * data[type]
 * data[name]
 * @todo: call back with an error if test-suite-end came with
 * a different test-suite than the one currently on top of the stack.
 * @todo: check for data to be an object to control this error
 */
Assigns test suite stack to each data object. Maintains a
test suite stack, and if a notification with type
'test-suite-start' is coming, the name of the test suite
is pushed onto the stack. When 'test-suite-end' notification
comes, the top item is popped from the stack.
data[type]
data[name]
@todo: call back with an error if test-suite-end came with
a different test-suite than the one currently on top of the stack.
@todo: check for data to be an object to control this error
Assigns test suite stack to each data object . Maintains a test suite stack and if a notification with type ' test - suite - start ' is coming the name of the test suite is pushed onto the stack . When ' test - suite - end ' notification comes the top item is popped from the stack . data [ type ] data [ name ] @todo : call back with an error if test - suite - end came with a different test - suite than the one currently on top of the stack . @todo : check for data to be an object to control this error
function createTestSuiteStackStream() {
  const testSuiteStack = []
  const ts = new Transform( ({
    objectMode: true,
    transform({ type, name, ...props }, encoding, callback) {
      if (type == 'test-suite-start' && name != 'default') {
        testSuiteStack.push(name)
      } else if (type == 'test-suite-end' && name != 'default') {
        testSuiteStack.pop()
      }
      const stack = testSuiteStack.slice()
      this.push({ type, name, stack, ...props })
      callback()
    },
  }))
  return ts
}
function createTestSuiteStackStream ( ) { const testSuiteStack = [ ] const ts = new Transform ( ( { objectMode : true , transform ( { type , name , ... props } , encoding , callback ) { if ( type == 'test-suite-start' && name != 'default' ) { testSuiteStack . push ( name ) } else if ( type == 'test-suite-end' && name != 'default' ) { testSuiteStack . pop ( ) } const stack = testSuiteStack . slice ( ) this . push ( { type , name , stack , ... props } ) callback ( ) } , } ) ) return ts }
Assigns test suite stack to each data object.
Assigns test suite stack to each data object .
/** @type {!stream.TransformOptions} */