(returnValue: string, expression = '$returnValue')
| 501 | const p = await r.launchAndLoad('blank'); |
| 502 | |
| 503 | const evaluateAtReturn = async (returnValue: string, expression = '$returnValue') => { |
| 504 | p.dap.evaluate({ |
| 505 | expression: `(function () { |
| 506 | debugger; |
| 507 | return ${returnValue}; |
| 508 | })();`, |
| 509 | }); |
| 510 | |
| 511 | const { threadId } = await p.dap.once('stopped'); |
| 512 | await p.dap.next({ threadId: threadId! }); // step past debugger; |
| 513 | await p.dap.once('stopped'); |
| 514 | await p.dap.next({ threadId: threadId! }); // step past return; |
| 515 | await p.dap.once('stopped'); |
| 516 | |
| 517 | const frameId = ( |
| 518 | await p.dap.stackTrace({ |
| 519 | threadId: threadId!, |
| 520 | }) |
| 521 | ).stackFrames[0].id; |
| 522 | |
| 523 | p.log(`return ${returnValue}:\n`); |
| 524 | await p.logger.evaluateAndLog(expression, { params: { frameId } }); |
| 525 | await p.dap.continue({ threadId: threadId! }); |
| 526 | }; |
| 527 | |
| 528 | await evaluateAtReturn('42'); |
| 529 | await evaluateAtReturn('{ a: { b: true } }'); |
no test coverage detected