@@ -3,6 +3,13 @@ import { Logger } from "../../src";
33import { getConsoleLog , mockConsoleLog } from "./helper.js" ;
44import { stdout } from "process" ;
55
6+ class CustomError extends Error {
7+ constructor ( message : string , public extraInfo : string ) {
8+ super ( message ) ;
9+ Object . setPrototypeOf ( this , CustomError . prototype ) ;
10+ }
11+ }
12+
613describe ( "Pretty: Log Types" , ( ) => {
714 beforeEach ( ( ) => {
815 mockConsoleLog ( true , false ) ;
@@ -117,6 +124,20 @@ describe("Pretty: Log Types", () => {
117124 expect ( ( errorLog ?. stack as any ) [ 0 ] ?. fileName ) . toBe ( "5_pretty_Log_Types.test.ts" ) ;
118125 } ) ;
119126
127+ test ( "Error with multiple parameters" , ( ) : void => {
128+ const logger = new Logger ( { type : "pretty" } ) ;
129+ const errorLog = logger . log ( 1234 , "testLevel" , new CustomError ( "Something went wrong" , "Additional info" ) ) ;
130+ expect ( getConsoleLog ( ) ) . toContain ( "Something went wrong" ) ;
131+ expect ( getConsoleLog ( ) ) . toContain ( "Additional info" ) ;
132+ expect ( getConsoleLog ( ) ) . toContain ( "Error" ) ;
133+ expect ( getConsoleLog ( ) ) . toContain ( "test" ) ;
134+ expect ( getConsoleLog ( ) ) . toContain ( "error stack:\n" ) ;
135+ expect ( getConsoleLog ( ) ) . toContain ( "5_pretty_Log_Types.test.ts" ) ;
136+ expect ( getConsoleLog ( ) ) . toContain ( "Object.<anonymous>" ) ;
137+ expect ( errorLog ?. nativeError ) . toBeInstanceOf ( Error ) ;
138+ expect ( ( errorLog ?. stack as any ) [ 0 ] ?. fileName ) . toBe ( "5_pretty_Log_Types.test.ts" ) ;
139+ } ) ;
140+
120141 test ( "string and Error" , ( ) : void => {
121142 const logger = new Logger ( { type : "pretty" } ) ;
122143 const errorLog = logger . log ( 1234 , "testLevel" , "test" , new Error ( "test" ) ) ;
0 commit comments