diff --git a/test/node-report/test-api-getreport.js b/test/node-report/test-api-getreport.js index 49e84d68a67ba9..780a5147b3f100 100644 --- a/test/node-report/test-api-getreport.js +++ b/test/node-report/test-api-getreport.js @@ -1,25 +1,12 @@ +// Flags: --experimental-report 'use strict'; - -// Testcase for returning report as a string via API call const common = require('../common'); common.skipIfReportDisabled(); const assert = require('assert'); -if (process.argv[2] === 'child') { - console.log(process.report.getReport()); -} else { - const helper = require('../common/report.js'); - const spawnSync = require('child_process').spawnSync; - const tmpdir = require('../common/tmpdir'); - tmpdir.refresh(); +const helper = require('../common/report'); - const args = ['--experimental-report', __filename, 'child']; - const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); - const report_msg = 'Found report files'; - const std_msg = 'Found messages on stderr'; - assert.ok(child.stderr.toString().includes( - `(node:${child.pid}) ExperimentalWarning: report is an` + - ' experimental feature. This feature could change at any time'), std_msg); - const reportFiles = helper.findReports(child.pid, tmpdir.path); - assert.deepStrictEqual(reportFiles, [], report_msg); - helper.validateContent(child.stdout); -} +common.expectWarning('ExperimentalWarning', + 'report is an experimental feature. This feature could ' + + 'change at any time'); +helper.validateContent(process.report.getReport()); +assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);