@@ -498,26 +498,27 @@ describe('raiseDiagnostics', () => {
498
498
category = ts . DiagnosticCategory . Warning ,
499
499
} : // eslint-disable-next-line @typescript-eslint/no-explicit-any
500
500
Partial < ts . Diagnostic > = { } ) : ts . Diagnostic => ( { messageText, code, category } as any )
501
- it ( 'should throw when diagnostics contains file path and exclude config matches file path' , ( ) => {
501
+ test ( 'should not throw when diagnostics contains file path and exclude config matches file path' , ( ) => {
502
502
const cs = createConfigSet ( {
503
503
logger,
504
504
tsJestConfig : { diagnostics : { exclude : [ 'src/__mocks__/index.ts' ] , pretty : false } } ,
505
505
} )
506
506
logger . target . clear ( )
507
507
508
- expect ( ( ) =>
509
- cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] , 'src/__mocks__/index.ts' , logger ) ,
510
- ) . toThrowErrorMatchingInlineSnapshot ( `"warning TS9999: foo"` )
508
+ expect ( ( ) => cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] , 'src/__mocks__/index.ts' , logger ) ) . not . toThrow ( )
511
509
} )
512
510
513
- it ( "should not throw when diagnostics contains file path and exclude config doesn't match file path" , ( ) => {
511
+ test ( "should throw when diagnostics contains file path and exclude config doesn't match file path" , ( ) => {
514
512
const cs = createConfigSet ( {
515
513
logger,
516
- tsJestConfig : { diagnostics : { warnOnly : true , exclude : [ '/bar/' ] , pretty : false } } ,
514
+ tsJestConfig : { diagnostics : { exclude : [ '/bar/' ] , pretty : false } } ,
517
515
} )
516
+ cs . compilerModule . formatDiagnostics = jest . fn ( ) . mockReturnValueOnce ( 'warning TS9999: foo' )
518
517
logger . target . clear ( )
519
518
520
- expect ( ( ) => cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] , 'src/__mocks__/index.ts' , logger ) ) . not . toThrow ( )
519
+ expect ( ( ) =>
520
+ cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] , 'src/__mocks__/index.ts' , logger ) ,
521
+ ) . toThrowErrorMatchingInlineSnapshot ( `"warning TS9999: foo"` )
521
522
} )
522
523
} )
523
524
@@ -536,41 +537,40 @@ describe('raiseDiagnostics', () => {
536
537
} : // eslint-disable-next-line @typescript-eslint/no-explicit-any
537
538
Partial < ts . Diagnostic > = { } ) : ts . Diagnostic => ( { messageText, code, category, file } as any )
538
539
539
- it ( " should not throw when exclude config doesn't match source file path" , ( ) => {
540
+ test ( ` should throw when exclude config doesn't match source file path` , ( ) => {
540
541
const cs = createConfigSet ( {
541
542
logger,
542
543
tsJestConfig : { diagnostics : { exclude : [ '/foo/' ] , pretty : false , ignoreCodes : [ 1111 ] } } ,
543
544
} )
545
+ cs . compilerModule . formatDiagnostics = jest . fn ( ) . mockReturnValueOnce ( 'warning TS9999: foo' )
544
546
logger . target . clear ( )
545
547
546
- expect ( ( ) => cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] ) ) . not . toThrow ( )
548
+ expect ( ( ) => cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] ) ) . toThrowErrorMatchingInlineSnapshot ( `"warning TS9999: foo"` )
547
549
} )
548
550
549
- it ( " should throw when exclude config doesn't match source file path" , ( ) => {
551
+ it ( ` should not throw when exclude config doesn't match source file path` , ( ) => {
550
552
const cs = createConfigSet ( {
551
553
logger,
552
554
tsJestConfig : { diagnostics : { exclude : [ 'src/__mocks__/index.ts' ] , pretty : false } } ,
553
555
} )
554
556
logger . target . clear ( )
555
557
556
- expect ( ( ) => cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] ) ) . toThrowErrorMatchingInlineSnapshot (
557
- `"Debug Failure. False expression: position cannot precede the beginning of the file"` ,
558
- )
558
+ expect ( ( ) => cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] ) ) . not . toThrow ( )
559
559
} )
560
560
} )
561
561
} ) // raiseDiagnostics
562
562
563
563
describe ( 'shouldReportDiagnostics' , ( ) => {
564
- it ( 'should return correct value for ts/tsx files' , ( ) => {
564
+ test ( 'should return correct value for ts/tsx files' , ( ) => {
565
565
let cs = createConfigSet ( {
566
566
tsJestConfig : {
567
567
tsconfig : false ,
568
- diagnostics : { exclude : [ '**/foo/*.ts' , '**/foo/*.tsx ' ] } ,
568
+ diagnostics : { exclude : [ '**/foo/*.ts' , 'NOTHING ' ] } ,
569
569
} as any , // eslint-disable-line @typescript-eslint/no-explicit-any
570
570
} )
571
571
572
- expect ( cs . shouldReportDiagnostics ( '/foo/index.ts' ) ) . toBe ( true )
573
- expect ( cs . shouldReportDiagnostics ( '/bar/index.tsx' ) ) . toBe ( false )
572
+ expect ( cs . shouldReportDiagnostics ( '/foo/index.ts' ) ) . toBe ( false )
573
+ expect ( cs . shouldReportDiagnostics ( '/bar/index.tsx' ) ) . toBe ( true )
574
574
575
575
// eslint-disable-next-line @typescript-eslint/no-explicit-any
576
576
cs = createConfigSet ( { tsJestConfig : { tsconfig : false } as any } )
@@ -597,8 +597,8 @@ describe('shouldReportDiagnostics', () => {
597
597
} ,
598
598
} )
599
599
600
- expect ( cs . shouldReportDiagnostics ( '/foo/index.js' ) ) . toBe ( true )
601
- expect ( cs . shouldReportDiagnostics ( '/foo/index.jsx' ) ) . toBe ( true )
600
+ expect ( cs . shouldReportDiagnostics ( '/foo/index.js' ) ) . toBe ( false )
601
+ expect ( cs . shouldReportDiagnostics ( '/foo/index.jsx' ) ) . toBe ( false )
602
602
} )
603
603
} ) // shouldReportDiagnostics
604
604
0 commit comments