()
| 37 | } |
| 38 | |
| 39 | async function test() { |
| 40 | // This interval ensures Node does not terminate till the test is finished. |
| 41 | // Inspector session does not keep the node process running (e.g. it does not |
| 42 | // have async handles on the main event loop). It is debatable whether this |
| 43 | // should be considered a bug, and there are no plans to fix it atm. |
| 44 | const interval = setInterval(() => {}, 5000); |
| 45 | session.connect(); |
| 46 | let traceNotification = null; |
| 47 | let tracingComplete = false; |
| 48 | session.on('NodeTracing.dataCollected', (n) => traceNotification = n); |
| 49 | session.on('NodeTracing.tracingComplete', () => tracingComplete = true); |
| 50 | const { categories } = await post('NodeTracing.getCategories'); |
| 51 | const expectedCategories = [ |
| 52 | 'node', |
| 53 | 'node.async_hooks', |
| 54 | 'node.bootstrap', |
| 55 | 'node.console', |
| 56 | 'node.dns.native', |
| 57 | 'node.environment', |
| 58 | 'node.fs.async', |
| 59 | 'node.fs.sync', |
| 60 | 'node.fs_dir.async', |
| 61 | 'node.fs_dir.sync', |
| 62 | 'node.http', |
| 63 | 'node.net.native', |
| 64 | 'node.perf', |
| 65 | 'node.perf.timerify', |
| 66 | 'node.perf.usertiming', |
| 67 | 'node.promises.rejections', |
| 68 | 'node.threadpoolwork.async', |
| 69 | 'node.threadpoolwork.sync', |
| 70 | 'node.vm.script', |
| 71 | 'v8', |
| 72 | ].sort(); |
| 73 | assert.ok(categories.length === expectedCategories.length); |
| 74 | categories.forEach((category, index) => { |
| 75 | const value = expectedCategories[index]; |
| 76 | assert.ok(category === value, `${category} is out of order, expect ${value}`); |
| 77 | }); |
| 78 | |
| 79 | const traceConfig = { includedCategories: ['v8'] }; |
| 80 | await post('NodeTracing.start', { traceConfig }); |
| 81 | |
| 82 | for (let i = 0; i < 5; i++) |
| 83 | await generateTrace(); |
| 84 | JSON.stringify(await post('NodeTracing.stop', { traceConfig })); |
| 85 | session.disconnect(); |
| 86 | assert(traceNotification.params.value.length > 0); |
| 87 | assert(tracingComplete); |
| 88 | clearInterval(interval); |
| 89 | console.log('Success'); |
| 90 | } |
| 91 | |
| 92 | test().then(common.mustCall()); |
no test coverage detected
searching dependent graphs…