1// Flags: --expose-internals 2 3'use strict'; 4 5// This tests `internal/errors.useOriginalName` 6// This testing feature is needed to allows us to assert the types of 7// errors without using instanceof, which is necessary in WPT harness. 8// Refs: https://github.com/nodejs/node/pull/22556 9 10require('../common'); 11const assert = require('assert'); 12const errors = require('internal/errors'); 13 14 15errors.E('TEST_ERROR_1', 'Error for testing purposes: %s', 16 Error); 17{ 18 const err = new errors.codes.TEST_ERROR_1('test'); 19 assert(err instanceof Error); 20 assert.strictEqual(err.name, 'Error'); 21} 22 23{ 24 errors.useOriginalName = true; 25 const err = new errors.codes.TEST_ERROR_1('test'); 26 assert(err instanceof Error); 27 assert.strictEqual(err.name, 'Error'); 28} 29 30{ 31 errors.useOriginalName = false; 32 const err = new errors.codes.TEST_ERROR_1('test'); 33 assert(err instanceof Error); 34 assert.strictEqual(err.name, 'Error'); 35} 36