MCPcopy Index your code
hub / github.com/nodejs/node / testBreakpoint

Function testBreakpoint

test/parallel/test-inspector-esm.js:47–101  ·  view source on GitHub ↗
(session)

Source from the content-addressed store, hash-verified

45}
46
47async function testBreakpoint(session) {
48 console.log('[test]', 'Setting a breakpoint and verifying it is hit');
49 const commands = [
50 { 'method': 'Debugger.setBreakpointByUrl',
51 'params': { 'lineNumber': 7,
52 'url': session.scriptURL(),
53 'columnNumber': 0,
54 'condition': '' } },
55 { 'method': 'Debugger.resume' },
56 ];
57 await session.send(commands);
58 const { scriptSource } = await session.send({
59 'method': 'Debugger.getScriptSource',
60 'params': { 'scriptId': session.mainScriptId },
61 });
62 assert(scriptSource && (scriptSource.includes(session.script())),
63 `Script source is wrong: ${scriptSource}`);
64
65 await session.waitForConsoleOutput('log', ['A message', 5]);
66 const paused = await session.waitForBreakOnLine(7, session.scriptURL());
67 const scopeId = paused.params.callFrames[0].scopeChain[0].object.objectId;
68
69 console.log('[test]', 'Verify we can read current application state');
70 const response = await session.send({
71 'method': 'Runtime.getProperties',
72 'params': {
73 'objectId': scopeId,
74 'ownProperties': false,
75 'accessorPropertiesOnly': false,
76 'generatePreview': true
77 }
78 });
79 assertScopeValues(response, { t: 1001, k: 1, message: 'A message' });
80
81 let { result } = await session.send({
82 'method': 'Debugger.evaluateOnCallFrame', 'params': {
83 'callFrameId': session.pausedDetails().callFrames[0].callFrameId,
84 'expression': 'k + t',
85 'objectGroup': 'console',
86 'includeCommandLineAPI': true,
87 'silent': false,
88 'returnByValue': false,
89 'generatePreview': true
90 }
91 });
92
93 assert.strictEqual(result.value, 1002);
94
95 result = (await session.send({
96 'method': 'Runtime.evaluate', 'params': {
97 'expression': '5 * 5'
98 }
99 })).result;
100 assert.strictEqual(result.value, 25);
101}
102
103async function runTest() {
104 const child = new NodeInstance(['--inspect-brk=0'], '',

Callers 1

runTestFunction · 0.70

Calls 10

scriptURLMethod · 0.80
includesMethod · 0.80
waitForConsoleOutputMethod · 0.80
waitForBreakOnLineMethod · 0.80
pausedDetailsMethod · 0.80
assertScopeValuesFunction · 0.70
sendMethod · 0.65
assertFunction · 0.50
logMethod · 0.45
scriptMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…