I am trying to parse unit test exception messages and separate them from the stack trace from st-out. The output is formatted like so:
Message:
Failed: expected invocation of Session.endDialog(It.isValue("login complete.")) exactly 1 times, invoked 0 times
Configured setups:
Session.endDialog(It.isValue("login complete."))
Performed invocations:
Session.sendTyping()
Session.endDialog("Login complete.")
Stack:
at Object.<anonymous> (<some path>\<some file>.spec.ts:274:19)
at fulfilled (<some path>\<some file>.spec.js:4:57)
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
The important bits are:
- There is always a
Message:
preceded by 2 spaces, followed by a newline. - What follows
Message:
is 1 or more lines of text possibly with consecutive newlines. - There is always a
Stack:
preceded by 2 spaces, followed by a newline. - What follows
Stack:
is 1 or more lines of stack trace type text.
The parser is a little complicated in that it is line based but supports loops and a different RegExp is needed to capture the various important parts for the message.
I have working expressions for everything, except for one. Basically I need a RegEx to match anything after the line with Message:
until the Stack:
, one line at a time.
Eg, it must match:
Failed: expected invocation of Session.endDialog(It.isValue("login complete.")) exactly 1 times, invoked 0 times`
and
Configured setups:
and
Session.endDialog(It.isValue("login complete."))
etc, but not
Stack:
I have tried using negative look-ahead with no luck, this is what I have so far:
\s+(?!Stack:).+