11import { createElement } from 'lwc' ;
22import FORM_FACTOR from '@salesforce/client/formFactor' ;
3+ import { LoggerStackTrace } from '../loggerStackTrace' ;
34// Recommended approach
45import { createLogger } from 'c/logger' ;
56// Legacy approach
@@ -186,7 +187,7 @@ describe('logger lwc import tests', () => {
186187 logEntryBuilder . setError ( error ) ;
187188
188189 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
189- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
190+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
190191 expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
191192 } ) ;
192193
@@ -211,7 +212,7 @@ describe('logger lwc import tests', () => {
211212 logEntryBuilder . setError ( error ) ;
212213
213214 expect ( logEntry . error . message ) . toEqual ( error . body . message ) ;
214- expect ( logEntry . error . stack ) . toEqual ( error . body . stackTrace ) ;
215+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
215216 expect ( logEntry . error . type ) . toEqual ( error . body . exceptionType ) ;
216217 } ) ;
217218
@@ -264,15 +265,15 @@ describe('logger lwc import tests', () => {
264265
265266 await flushPromises ( ) ;
266267 expect ( logger . getBufferSize ( ) ) . toEqual ( 0 ) ;
268+ expect ( logEntry . error . message ) . toEqual ( error . message ) ;
269+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
270+ expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
267271 expect ( logEntry . loggingLevel ) . toEqual ( 'ERROR' ) ;
268- expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
272+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
269273 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
270- expect ( logEntry . error ) . toBeTruthy ( ) ;
271- expect ( logEntry . stack ) . toBeTruthy ( ) ;
272- expect ( logEntry . error . message ) . toEqual ( error . message ) ;
273- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
274- expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
274+ expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
275275 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
276+ expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
276277 } ) ;
277278
278279 it ( 'still works for WARN logging level when disabled when using recommended import approach' , async ( ) => {
@@ -294,15 +295,15 @@ describe('logger lwc import tests', () => {
294295
295296 await flushPromises ( ) ;
296297 expect ( logger . getBufferSize ( ) ) . toEqual ( 0 ) ;
298+ expect ( logEntry . error . message ) . toEqual ( error . message ) ;
299+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
300+ expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
297301 expect ( logEntry . loggingLevel ) . toEqual ( 'WARN' ) ;
298- expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
302+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
299303 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
300- expect ( logEntry . error ) . toBeTruthy ( ) ;
301- expect ( logEntry . stack ) . toBeTruthy ( ) ;
302- expect ( logEntry . error . message ) . toEqual ( error . message ) ;
303- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
304- expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
304+ expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
305305 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
306+ expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
306307 } ) ;
307308
308309 it ( 'still works for INFO logging level when disabled when using recommended import approach' , async ( ) => {
@@ -324,15 +325,15 @@ describe('logger lwc import tests', () => {
324325
325326 await flushPromises ( ) ;
326327 expect ( logger . getBufferSize ( ) ) . toEqual ( 0 ) ;
328+ expect ( logEntry . error . message ) . toEqual ( error . message ) ;
329+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
330+ expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
327331 expect ( logEntry . loggingLevel ) . toEqual ( 'INFO' ) ;
328- expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
332+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
329333 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
330- expect ( logEntry . error ) . toBeTruthy ( ) ;
331- expect ( logEntry . stack ) . toBeTruthy ( ) ;
332- expect ( logEntry . error . message ) . toEqual ( error . message ) ;
333- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
334- expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
334+ expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
335335 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
336+ expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
336337 } ) ;
337338
338339 it ( 'still works for DEBUG logging level when disabled when using recommended import approach' , async ( ) => {
@@ -354,15 +355,15 @@ describe('logger lwc import tests', () => {
354355
355356 await flushPromises ( ) ;
356357 expect ( logger . getBufferSize ( ) ) . toEqual ( 0 ) ;
358+ expect ( logEntry . error . message ) . toEqual ( error . message ) ;
359+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
360+ expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
357361 expect ( logEntry . loggingLevel ) . toEqual ( 'DEBUG' ) ;
358- expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
362+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
359363 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
360- expect ( logEntry . error ) . toBeTruthy ( ) ;
361- expect ( logEntry . stack ) . toBeTruthy ( ) ;
362- expect ( logEntry . error . message ) . toEqual ( error . message ) ;
363- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
364- expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
364+ expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
365365 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
366+ expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
366367 } ) ;
367368
368369 it ( 'still works for FINE logging level when disabled when using recommended import approach' , async ( ) => {
@@ -384,15 +385,15 @@ describe('logger lwc import tests', () => {
384385
385386 await flushPromises ( ) ;
386387 expect ( logger . getBufferSize ( ) ) . toEqual ( 0 ) ;
388+ expect ( logEntry . error . message ) . toEqual ( error . message ) ;
389+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
390+ expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
387391 expect ( logEntry . loggingLevel ) . toEqual ( 'FINE' ) ;
388- expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
392+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
389393 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
390- expect ( logEntry . error ) . toBeTruthy ( ) ;
391- expect ( logEntry . stack ) . toBeTruthy ( ) ;
392- expect ( logEntry . error . message ) . toEqual ( error . message ) ;
393- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
394- expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
394+ expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
395395 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
396+ expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
396397 } ) ;
397398
398399 it ( 'still works for FINER logging level when disabled when using recommended import approach' , async ( ) => {
@@ -414,15 +415,15 @@ describe('logger lwc import tests', () => {
414415
415416 await flushPromises ( ) ;
416417 expect ( logger . getBufferSize ( ) ) . toEqual ( 0 ) ;
418+ expect ( logEntry . error . message ) . toEqual ( error . message ) ;
419+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
420+ expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
417421 expect ( logEntry . loggingLevel ) . toEqual ( 'FINER' ) ;
418- expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
422+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
419423 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
420- expect ( logEntry . error ) . toBeTruthy ( ) ;
421- expect ( logEntry . stack ) . toBeTruthy ( ) ;
422- expect ( logEntry . error . message ) . toEqual ( error . message ) ;
423- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
424- expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
424+ expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
425425 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
426+ expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
426427 } ) ;
427428
428429 it ( 'still works for FINEST logging level when disabled when using recommended import approach' , async ( ) => {
@@ -444,15 +445,15 @@ describe('logger lwc import tests', () => {
444445
445446 await flushPromises ( ) ;
446447 expect ( logger . getBufferSize ( ) ) . toEqual ( 0 ) ;
448+ expect ( logEntry . error . message ) . toEqual ( error . message ) ;
449+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
450+ expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
447451 expect ( logEntry . loggingLevel ) . toEqual ( 'FINEST' ) ;
448- expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
452+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
449453 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
450- expect ( logEntry . error ) . toBeTruthy ( ) ;
451- expect ( logEntry . stack ) . toBeTruthy ( ) ;
452- expect ( logEntry . error . message ) . toEqual ( error . message ) ;
453- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
454- expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
454+ expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
455455 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
456+ expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
456457 } ) ;
457458
458459 it ( 'flushes buffer when using recommended import approach' , async ( ) => {
@@ -668,7 +669,7 @@ describe('logger lwc legacy markup tests', () => {
668669 logEntryBuilder . setError ( error ) ;
669670
670671 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
671- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
672+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
672673 expect ( logEntry . error . type ) . toEqual ( 'JavaScript.TypeError' ) ;
673674 } ) ;
674675
@@ -695,7 +696,7 @@ describe('logger lwc legacy markup tests', () => {
695696 logEntryBuilder . setError ( error ) ;
696697
697698 expect ( logEntry . error . message ) . toEqual ( error . body . message ) ;
698- expect ( logEntry . error . stack ) . toEqual ( error . body . stackTrace ) ;
699+ expect ( logEntry . error . stackTrace ) . toEqual ( error . body . stackTrace ) ;
699700 expect ( logEntry . error . type ) . toEqual ( error . body . exceptionType ) ;
700701 } ) ;
701702
@@ -757,9 +758,9 @@ describe('logger lwc legacy markup tests', () => {
757758 expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
758759 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
759760 expect ( logEntry . error ) . toBeTruthy ( ) ;
760- expect ( logEntry . stack ) . toBeTruthy ( ) ;
761+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
761762 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
762- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
763+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
763764 expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
764765 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
765766 } ) ;
@@ -788,9 +789,9 @@ describe('logger lwc legacy markup tests', () => {
788789 expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
789790 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
790791 expect ( logEntry . error ) . toBeTruthy ( ) ;
791- expect ( logEntry . stack ) . toBeTruthy ( ) ;
792+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
792793 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
793- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
794+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
794795 expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
795796 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
796797 } ) ;
@@ -819,9 +820,9 @@ describe('logger lwc legacy markup tests', () => {
819820 expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
820821 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
821822 expect ( logEntry . error ) . toBeTruthy ( ) ;
822- expect ( logEntry . stack ) . toBeTruthy ( ) ;
823+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
823824 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
824- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
825+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
825826 expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
826827 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
827828 } ) ;
@@ -850,9 +851,9 @@ describe('logger lwc legacy markup tests', () => {
850851 expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
851852 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
852853 expect ( logEntry . error ) . toBeTruthy ( ) ;
853- expect ( logEntry . stack ) . toBeTruthy ( ) ;
854+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
854855 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
855- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
856+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
856857 expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
857858 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
858859 } ) ;
@@ -881,9 +882,9 @@ describe('logger lwc legacy markup tests', () => {
881882 expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
882883 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
883884 expect ( logEntry . error ) . toBeTruthy ( ) ;
884- expect ( logEntry . stack ) . toBeTruthy ( ) ;
885+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
885886 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
886- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
887+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
887888 expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
888889 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
889890 } ) ;
@@ -919,9 +920,9 @@ describe('logger lwc legacy markup tests', () => {
919920 expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
920921 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
921922 expect ( logEntry . error ) . toBeTruthy ( ) ;
922- expect ( logEntry . stack ) . toBeTruthy ( ) ;
923+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
923924 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
924- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
925+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
925926 expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
926927 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
927928 } ) ;
@@ -951,9 +952,9 @@ describe('logger lwc legacy markup tests', () => {
951952 expect ( logEntry . recordId ) . toEqual ( 'some_record_Id' ) ;
952953 expect ( logEntry . record ) . toEqual ( { Id : 'some_record_Id' } ) ;
953954 expect ( logEntry . error ) . toBeTruthy ( ) ;
954- expect ( logEntry . stack ) . toBeTruthy ( ) ;
955+ expect ( logEntry . originStackTrace ) . toBeTruthy ( ) ;
955956 expect ( logEntry . error . message ) . toEqual ( error . message ) ;
956- expect ( logEntry . error . stack ) . toEqual ( error . stack ) ;
957+ expect ( logEntry . error . stackTrace ) . toBeTruthy ( ) ;
957958 expect ( logEntry . timestamp ) . toBeTruthy ( ) ;
958959 expect ( logEntry . tags ) . toEqual ( [ 'a tag' , 'a second tag' , 'a third tag' ] ) ;
959960 } ) ;
0 commit comments