• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2// Test producing a report on uncaught exception.
3const common = require('../common');
4const assert = require('assert');
5const childProcess = require('child_process');
6const helper = require('../common/report');
7const tmpdir = require('../common/tmpdir');
8
9if (process.argv[2] === 'child') {
10  // eslint-disable-next-line no-throw-literal
11  throw 1;
12}
13
14tmpdir.refresh();
15const child = childProcess.spawn(process.execPath, [
16  '--report-uncaught-exception',
17  __filename,
18  'child',
19], {
20  cwd: tmpdir.path,
21});
22child.on('exit', common.mustCall((code) => {
23  assert.strictEqual(code, 1);
24  const reports = helper.findReports(child.pid, tmpdir.path);
25  assert.strictEqual(reports.length, 1);
26
27  helper.validate(reports[0], [
28    ['header.event', 'Exception'],
29    ['header.trigger', 'Exception'],
30    ['javascriptStack.message', '1'],
31  ]);
32}));
33