UNPKG

@tapjs/node-serialize

Version:

Stream TAP test data as a serialized node:test stream

25 lines 803 B
import { testNestedLocation } from './test-nested-location.js'; export const onAddFn = (comment, diagsMap, subsMap) => { const onAdd = (t) => { const tt = t; const subs = []; const diags = diagsMap.get(t) || []; subsMap.set(t, subs); diagsMap.set(t, diags); if (typeof tt.comment === 'function') { tt.comment = comment; } else if (!tt.comment) { t.parser.on('comment', message => { message = message.replace(/^#/, '').trim(); diags.push({ ...testNestedLocation(t), message }); }); } tt.on('subtestAdd', onAdd); if (t.parent) { subsMap.get(t.parent)?.push(t); } }; return onAdd; }; //# sourceMappingURL=on-add.js.map