(returnValue: string, expression = '$returnValue')
| 459 | const p = await r.launchAndLoad('blank'); |
| 460 | |
| 461 | const evaluateAtReturn = async (returnValue: string, expression = '$returnValue') => { |
| 462 | p.dap.evaluate({ |
| 463 | expression: `(function () { |
| 464 | debugger; |
| 465 | return ${returnValue}; |
| 466 | })();`, |
| 467 | }); |
| 468 | |
| 469 | const { threadId } = await p.dap.once('stopped'); |
| 470 | await p.dap.next({ threadId: threadId! }); // step past debugger; |
| 471 | await p.dap.once('stopped'); |
| 472 | await p.dap.next({ threadId: threadId! }); // step past return; |
| 473 | await p.dap.once('stopped'); |
| 474 | |
| 475 | const frameId = ( |
| 476 | await p.dap.stackTrace({ |
| 477 | threadId: threadId!, |
| 478 | }) |
| 479 | ).stackFrames[0].id; |
| 480 | |
| 481 | p.log(`return ${returnValue}:\n`); |
| 482 | await p.logger.evaluateAndLog(expression, { params: { frameId } }); |
| 483 | await p.dap.continue({ threadId: threadId! }); |
| 484 | }; |
| 485 | |
| 486 | await evaluateAtReturn('42'); |
| 487 | await evaluateAtReturn('{ a: { b: true } }'); |
no test coverage detected