0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/report/test-report-getreport.js
himself65 c25cccf130 test: check getReport when error with one line stack
PR-URL: https://github.com/nodejs/node/pull/28433
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-07-05 22:47:05 -07:00

38 lines
1.2 KiB
JavaScript

// Flags: --experimental-report
'use strict';
const common = require('../common');
common.skipIfReportDisabled();
const assert = require('assert');
const helper = require('../common/report');
common.expectWarning('ExperimentalWarning',
'report is an experimental feature. This feature could ' +
'change at any time');
{
// Test with no arguments.
helper.validateContent(process.report.getReport());
assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);
}
{
// Test with an error argument.
helper.validateContent(process.report.getReport(new Error('test error')));
assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);
}
{
// Test with an error with one line stack
const error = new Error();
error.stack = 'only one line';
helper.validateContent(process.report.getReport(error));
assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);
}
// Test with an invalid error argument.
[null, 1, Symbol(), function() {}, 'foo'].forEach((error) => {
common.expectsError(() => {
process.report.getReport(error);
}, { code: 'ERR_INVALID_ARG_TYPE' });
});