1import { spawnPromisified } from '../common/index.mjs'; 2import assert from 'node:assert'; 3import { execPath } from 'node:process'; 4import { describe, it } from 'node:test'; 5 6 7describe('--trace-uncaught', () => { 8 it('prints a trace on process exit for uncaught errors', async () => { 9 const { code, signal, stderr } = await spawnPromisified(execPath, [ 10 '--trace-uncaught', 11 '--eval', 12 `throw { 13 get stack() { 14 throw new Error('weird throw but ok'); 15 }, 16 get name() { 17 throw new Error('weird throw but ok'); 18 }, 19 };`, 20 ]); 21 22 assert.match(stderr, /^Thrown at:$/m); 23 assert.match(stderr, /^ {4}at \[eval\]:1:1$/m); 24 assert.strictEqual(code, 1); 25 assert.strictEqual(signal, null); 26 }); 27}); 28