@@ -56,7 +56,7 @@ describe('createRunnerFunction', () => {
5656 it ( 'should return empty array if no diagnostics are found' , ( ) => {
5757 getTypeScriptDiagnosticsSpy . mockReturnValue ( [ ] ) ;
5858 const runner = createRunnerFunction ( {
59- tsconfig : 'tsconfig.json' ,
59+ tsconfig : [ 'tsconfig.json' ] ,
6060 expectedAudits : [ ] ,
6161 } ) ;
6262 expect ( runner ( runnerArgs ) ) . toStrictEqual ( [ ] ) ;
@@ -65,7 +65,7 @@ describe('createRunnerFunction', () => {
6565 it ( 'should return empty array if no supported diagnostics are found' , ( ) => {
6666 getTypeScriptDiagnosticsSpy . mockReturnValue ( [ mockSemanticDiagnostic ] ) ;
6767 const runner = createRunnerFunction ( {
68- tsconfig : 'tsconfig.json' ,
68+ tsconfig : [ 'tsconfig.json' ] ,
6969 expectedAudits : [ ] ,
7070 } ) ;
7171 expect ( runner ( runnerArgs ) ) . toStrictEqual ( [ ] ) ;
@@ -74,7 +74,7 @@ describe('createRunnerFunction', () => {
7474 it ( 'should pass the diagnostic code to tsCodeToSlug' , ( ) => {
7575 getTypeScriptDiagnosticsSpy . mockReturnValue ( [ mockSemanticDiagnostic ] ) ;
7676 const runner = createRunnerFunction ( {
77- tsconfig : 'tsconfig.json' ,
77+ tsconfig : [ 'tsconfig.json' ] ,
7878 expectedAudits : [ ] ,
7979 } ) ;
8080 expect ( runner ( runnerArgs ) ) . toStrictEqual ( [ ] ) ;
@@ -85,7 +85,7 @@ describe('createRunnerFunction', () => {
8585 it ( 'should pass the diagnostic to getIssueFromDiagnostic' , ( ) => {
8686 getTypeScriptDiagnosticsSpy . mockReturnValue ( [ mockSemanticDiagnostic ] ) ;
8787 const runner = createRunnerFunction ( {
88- tsconfig : 'tsconfig.json' ,
88+ tsconfig : [ 'tsconfig.json' ] ,
8989 expectedAudits : [ ] ,
9090 } ) ;
9191 expect ( runner ( runnerArgs ) ) . toStrictEqual ( [ ] ) ;
@@ -106,7 +106,7 @@ describe('createRunnerFunction', () => {
106106 } ,
107107 ] ) ;
108108 const runner = createRunnerFunction ( {
109- tsconfig : 'tsconfig.json' ,
109+ tsconfig : [ 'tsconfig.json' ] ,
110110 expectedAudits : [ { slug : 'semantic-errors' } ] ,
111111 } ) ;
112112
@@ -138,7 +138,7 @@ describe('createRunnerFunction', () => {
138138 mockSemanticDiagnostic ,
139139 ] ) ;
140140 const runner = createRunnerFunction ( {
141- tsconfig : 'tsconfig.json' ,
141+ tsconfig : [ 'tsconfig.json' ] ,
142142 expectedAudits : [ { slug : 'semantic-errors' } , { slug : 'syntax-errors' } ] ,
143143 } ) ;
144144
@@ -181,10 +181,54 @@ describe('createRunnerFunction', () => {
181181 } ,
182182 ] ) ;
183183 const runner = createRunnerFunction ( {
184- tsconfig : 'tsconfig.json' ,
184+ tsconfig : [ 'tsconfig.json' ] ,
185185 expectedAudits : [ { slug : 'semantic-errors' } , { slug : 'syntax-errors' } ] ,
186186 } ) ;
187187 const auditOutputs = runner ( runnerArgs ) ;
188188 expect ( ( ) => auditOutputsSchema . parse ( auditOutputs ) ) . not . toThrow ( ) ;
189189 } ) ;
190+
191+ it ( 'should aggregate diagnostics from multiple tsconfigs' , ( ) => {
192+ getTypeScriptDiagnosticsSpy
193+ . mockReturnValueOnce ( [ mockSemanticDiagnostic ] )
194+ . mockReturnValueOnce ( [ mockSyntacticDiagnostic ] ) ;
195+
196+ const runner = createRunnerFunction ( {
197+ tsconfig : [ 'tsconfig.lib.json' , 'tsconfig.spec.json' ] ,
198+ expectedAudits : [ { slug : 'semantic-errors' } , { slug : 'syntax-errors' } ] ,
199+ } ) ;
200+
201+ const auditOutputs = runner ( runnerArgs ) ;
202+
203+ expect ( getTypeScriptDiagnosticsSpy ) . toHaveBeenCalledTimes ( 2 ) ;
204+ expect ( getTypeScriptDiagnosticsSpy ) . toHaveBeenNthCalledWith ( 1 , {
205+ tsconfig : 'tsconfig.lib.json' ,
206+ } ) ;
207+ expect ( getTypeScriptDiagnosticsSpy ) . toHaveBeenNthCalledWith ( 2 , {
208+ tsconfig : 'tsconfig.spec.json' ,
209+ } ) ;
210+
211+ expect ( auditOutputs ) . toStrictEqual ( [
212+ expect . objectContaining ( {
213+ slug : 'semantic-errors' ,
214+ value : 1 ,
215+ details : {
216+ issues : [
217+ expect . objectContaining ( {
218+ message : `TS2322: Type 'string' is not assignable to type 'number'.` ,
219+ } ) ,
220+ ] ,
221+ } ,
222+ } ) ,
223+ expect . objectContaining ( {
224+ slug : 'syntax-errors' ,
225+ value : 1 ,
226+ details : {
227+ issues : [
228+ expect . objectContaining ( { message : "TS1005: ';' expected." } ) ,
229+ ] ,
230+ } ,
231+ } ) ,
232+ ] ) ;
233+ } ) ;
190234} ) ;
0 commit comments