Closed gregorskii closed 4 years ago
I think you probably want to be using the complete
event rather than the stream end
event. The end
event is simply signifying that all of the input has been consumed and thus no more should be written, but the processing of that input happens after it's been consumed.
Something like this: https://gist.github.com/isaacs/e4cd8a418372e5a15235e33347de8d06
We could defer end
events until after the parser emits complete
, but it'd be kind of complicated, and I'm not sure it provides much value.
Hi all,
I am working on a project where grouping results by subtest is preferred. I am finding that it is quite difficult to track and group assertions by subtests starting and ending.
The parser will correctly emit a child parser, but the child parser itself does not emit assertions / pass / fails that it finds. It also emits its "complete" event before the assertions are emitted from the top level parser.
For example given this example parser:
The assertions appear AFTER the child emits an end. This makes it quite difficult to write an algo that will catch any assertions (pass or fail) within a known buffer.
I am trying to create some base parser logic that will start a recursive stack on the beginning of a subtest, then any assertions get thrown in an array / map for the specific test depth we are on. Once it detects that the current child has ended it will unwind the stack and build a data structure that has the assertions grouped by subtest.
I have looked over all of the example Tap parsers and none of them group by test, they assume the result is a stream of assertions at the top level. Which makes sense, as the test that are reporting in the console are linear, and read line for line like the tap output. But this limitation is potentially stopping parsers from being able to group results by subtests.
I hope that makes sense... :/
Here is an example:
Test:
In my actual test describe is
async
and it awaitsassumeThisWasTheAsyncData
, this is an interesting and amazing feature of tap as its so low level it can allow async describe blocks with tests inside, unlike say Jest or Jasmine. See https://github.com/jasmine/jasmine/issues/1487.Parser Output:
Tap Output:
Let me know if you need anymore context. I hope I explained it well enough.