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

Function testSampleDebugSession

test/parallel/test-inspector-bindings.js:59–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57}
58
59function testSampleDebugSession() {
60 let cur = 0;
61 const failures = [];
62 const expects = {
63 i: [0, 1, 2, 3, 4],
64 accum: [0, 0, 1, 3, 6]
65 };
66 scopeCallback = function(error, result) {
67 const i = cur++;
68 let v, actual, expected;
69 for (v of result.result) {
70 actual = v.value.value;
71 expected = expects[v.name][i];
72 if (actual !== expected) {
73 failures.push(`Iteration ${i} variable: ${v.name} ` +
74 `expected: ${expected} actual: ${actual}`);
75 }
76 }
77 };
78 const session = new inspector.Session();
79 session.connect();
80 session.on('Debugger.paused',
81 (notification) => debuggerPausedCallback(session, notification));
82 let cbAsSecondArgCalled = false;
83 assert.throws(() => {
84 session.post('Debugger.enable', function() {}, function() {});
85 }, TypeError);
86 session.post('Debugger.enable', () => cbAsSecondArgCalled = true);
87 session.post('Debugger.setBreakpointByUrl', {
88 'lineNumber': 13,
89 'url': pathToFileURL(path.resolve(__dirname, __filename)).toString(),
90 'columnNumber': 0,
91 'condition': ''
92 });
93
94 debuggedFunction();
95 assert.strictEqual(cbAsSecondArgCalled, true);
96 assert.deepStrictEqual(failures, []);
97 assert.strictEqual(cur, 5);
98 scopeCallback = null;
99 session.disconnect();
100 assert.throws(() => session.post('Debugger.enable'), (e) => !!e);
101}
102
103async function testNoCrashConsoleLogBeforeThrow() {
104 const session = new inspector.Session();

Callers 1

doTestsFunction · 0.85

Calls 10

connectMethod · 0.95
postMethod · 0.95
disconnectMethod · 0.95
debuggerPausedCallbackFunction · 0.85
debuggedFunctionFunction · 0.85
pathToFileURLFunction · 0.50
pushMethod · 0.45
onMethod · 0.45
toStringMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…