Skip to content

Commit bc11415

Browse files
cjihrigrvagg
authored andcommitted
test: simplify test-api-nohooks.js
PR-URL: #26217 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent dbbceda commit bc11415

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

test/node-report/test-api-nohooks.js

+14-23
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1+
// Flags: --experimental-report
12
'use strict';
23

3-
// Testcase to produce report via API call, using the no-hooks/no-signal
4-
// interface - i.e. require('node-report/api')
4+
// Test producing a report via API call, using the no-hooks/no-signal interface.
55
const common = require('../common');
66
common.skipIfReportDisabled();
7-
if (process.argv[2] === 'child') {
8-
process.report.triggerReport();
9-
} else {
10-
const helper = require('../common/report.js');
11-
const spawn = require('child_process').spawn;
12-
const assert = require('assert');
13-
const tmpdir = require('../common/tmpdir');
14-
tmpdir.refresh();
7+
const assert = require('assert');
8+
const helper = require('../common/report');
9+
const tmpdir = require('../common/tmpdir');
1510

16-
const child = spawn(process.execPath, ['--experimental-report',
17-
__filename, 'child'],
18-
{ cwd: tmpdir.path });
19-
child.on('exit', common.mustCall((code) => {
20-
const report_msg = 'No reports found';
21-
const process_msg = 'Process exited unexpectedly';
22-
assert.strictEqual(code, 0, process_msg + ':' + code);
23-
const reports = helper.findReports(child.pid, tmpdir.path);
24-
assert.strictEqual(reports.length, 1, report_msg);
25-
const report = reports[0];
26-
helper.validate(report);
27-
}));
28-
}
11+
common.expectWarning('ExperimentalWarning',
12+
'report is an experimental feature. This feature could ' +
13+
'change at any time');
14+
tmpdir.refresh();
15+
process.report.setOptions({ path: tmpdir.path });
16+
process.report.triggerReport();
17+
const reports = helper.findReports(process.pid, tmpdir.path);
18+
assert.strictEqual(reports.length, 1);
19+
helper.validate(reports[0]);

0 commit comments

Comments
 (0)