@@ -498,26 +498,27 @@ describe('raiseDiagnostics', () => {
498498 category = ts . DiagnosticCategory . Warning ,
499499 } : // eslint-disable-next-line @typescript-eslint/no-explicit-any
500500 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' , ( ) => {
502502 const cs = createConfigSet ( {
503503 logger,
504504 tsJestConfig : { diagnostics : { exclude : [ 'src/__mocks__/index.ts' ] , pretty : false } } ,
505505 } )
506506 logger . target . clear ( )
507507
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 ( )
511509 } )
512510
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" , ( ) => {
514512 const cs = createConfigSet ( {
515513 logger,
516- tsJestConfig : { diagnostics : { warnOnly : true , exclude : [ '/bar/' ] , pretty : false } } ,
514+ tsJestConfig : { diagnostics : { exclude : [ '/bar/' ] , pretty : false } } ,
517515 } )
516+ cs . compilerModule . formatDiagnostics = jest . fn ( ) . mockReturnValueOnce ( 'warning TS9999: foo' )
518517 logger . target . clear ( )
519518
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"` )
521522 } )
522523 } )
523524
@@ -536,41 +537,40 @@ describe('raiseDiagnostics', () => {
536537 } : // eslint-disable-next-line @typescript-eslint/no-explicit-any
537538 Partial < ts . Diagnostic > = { } ) : ts . Diagnostic => ( { messageText, code, category, file } as any )
538539
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` , ( ) => {
540541 const cs = createConfigSet ( {
541542 logger,
542543 tsJestConfig : { diagnostics : { exclude : [ '/foo/' ] , pretty : false , ignoreCodes : [ 1111 ] } } ,
543544 } )
545+ cs . compilerModule . formatDiagnostics = jest . fn ( ) . mockReturnValueOnce ( 'warning TS9999: foo' )
544546 logger . target . clear ( )
545547
546- expect ( ( ) => cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] ) ) . not . toThrow ( )
548+ expect ( ( ) => cs . raiseDiagnostics ( [ makeDiagnostic ( ) ] ) ) . toThrowErrorMatchingInlineSnapshot ( `"warning TS9999: foo"` )
547549 } )
548550
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` , ( ) => {
550552 const cs = createConfigSet ( {
551553 logger,
552554 tsJestConfig : { diagnostics : { exclude : [ 'src/__mocks__/index.ts' ] , pretty : false } } ,
553555 } )
554556 logger . target . clear ( )
555557
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 ( )
559559 } )
560560 } )
561561} ) // raiseDiagnostics
562562
563563describe ( 'shouldReportDiagnostics' , ( ) => {
564- it ( 'should return correct value for ts/tsx files' , ( ) => {
564+ test ( 'should return correct value for ts/tsx files' , ( ) => {
565565 let cs = createConfigSet ( {
566566 tsJestConfig : {
567567 tsconfig : false ,
568- diagnostics : { exclude : [ '**/foo/*.ts' , '**/foo/*.tsx ' ] } ,
568+ diagnostics : { exclude : [ '**/foo/*.ts' , 'NOTHING ' ] } ,
569569 } as any , // eslint-disable-line @typescript-eslint/no-explicit-any
570570 } )
571571
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 )
574574
575575 // eslint-disable-next-line @typescript-eslint/no-explicit-any
576576 cs = createConfigSet ( { tsJestConfig : { tsconfig : false } as any } )
@@ -597,8 +597,8 @@ describe('shouldReportDiagnostics', () => {
597597 } ,
598598 } )
599599
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 )
602602 } )
603603} ) // shouldReportDiagnostics
604604
0 commit comments