@@ -4,7 +4,11 @@ import {
44 type SourceFile ,
55} from 'typescript' ;
66import { beforeEach , describe , expect } from 'vitest' ;
7- import { auditOutputsSchema } from '@code-pushup/models' ;
7+ import {
8+ DEFAULT_PERSIST_CONFIG ,
9+ type RunnerArgs ,
10+ auditOutputsSchema ,
11+ } from '@code-pushup/models' ;
812import { createRunnerFunction } from './runner.js' ;
913import * as runnerModule from './ts-runner.js' ;
1014import * as utilsModule from './utils.js' ;
@@ -20,6 +24,8 @@ describe('createRunnerFunction', () => {
2024 'getIssueFromDiagnostic' ,
2125 ) ;
2226
27+ const runnerArgs : RunnerArgs = { persist : DEFAULT_PERSIST_CONFIG } ;
28+
2329 const semanticTsCode = 2322 ;
2430 const mockSemanticDiagnostic = {
2531 code : semanticTsCode , // "Type 'string' is not assignable to type 'number'"
@@ -47,51 +53,51 @@ describe('createRunnerFunction', () => {
4753 getTypeScriptDiagnosticsSpy . mockReset ( ) ;
4854 } ) ;
4955
50- it ( 'should return empty array if no diagnostics are found' , async ( ) => {
51- getTypeScriptDiagnosticsSpy . mockResolvedValue ( [ ] ) ;
56+ it ( 'should return empty array if no diagnostics are found' , ( ) => {
57+ getTypeScriptDiagnosticsSpy . mockReturnValue ( [ ] ) ;
5258 const runner = createRunnerFunction ( {
5359 tsconfig : 'tsconfig.json' ,
5460 expectedAudits : [ ] ,
5561 } ) ;
56- await expect ( runner ( ( ) => void 0 ) ) . resolves . toStrictEqual ( [ ] ) ;
62+ expect ( runner ( runnerArgs ) ) . toStrictEqual ( [ ] ) ;
5763 } ) ;
5864
59- it ( 'should return empty array if no supported diagnostics are found' , async ( ) => {
60- getTypeScriptDiagnosticsSpy . mockResolvedValue ( [ mockSemanticDiagnostic ] ) ;
65+ it ( 'should return empty array if no supported diagnostics are found' , ( ) => {
66+ getTypeScriptDiagnosticsSpy . mockReturnValue ( [ mockSemanticDiagnostic ] ) ;
6167 const runner = createRunnerFunction ( {
6268 tsconfig : 'tsconfig.json' ,
6369 expectedAudits : [ ] ,
6470 } ) ;
65- await expect ( runner ( ( ) => void 0 ) ) . resolves . toStrictEqual ( [ ] ) ;
71+ expect ( runner ( runnerArgs ) ) . toStrictEqual ( [ ] ) ;
6672 } ) ;
6773
68- it ( 'should pass the diagnostic code to tsCodeToSlug' , async ( ) => {
69- getTypeScriptDiagnosticsSpy . mockResolvedValue ( [ mockSemanticDiagnostic ] ) ;
74+ it ( 'should pass the diagnostic code to tsCodeToSlug' , ( ) => {
75+ getTypeScriptDiagnosticsSpy . mockReturnValue ( [ mockSemanticDiagnostic ] ) ;
7076 const runner = createRunnerFunction ( {
7177 tsconfig : 'tsconfig.json' ,
7278 expectedAudits : [ ] ,
7379 } ) ;
74- await expect ( runner ( ( ) => void 0 ) ) . resolves . toStrictEqual ( [ ] ) ;
80+ expect ( runner ( runnerArgs ) ) . toStrictEqual ( [ ] ) ;
7581 expect ( tSCodeToAuditSlugSpy ) . toHaveBeenCalledTimes ( 1 ) ;
7682 expect ( tSCodeToAuditSlugSpy ) . toHaveBeenCalledWith ( semanticTsCode ) ;
7783 } ) ;
7884
79- it ( 'should pass the diagnostic to getIssueFromDiagnostic' , async ( ) => {
80- getTypeScriptDiagnosticsSpy . mockResolvedValue ( [ mockSemanticDiagnostic ] ) ;
85+ it ( 'should pass the diagnostic to getIssueFromDiagnostic' , ( ) => {
86+ getTypeScriptDiagnosticsSpy . mockReturnValue ( [ mockSemanticDiagnostic ] ) ;
8187 const runner = createRunnerFunction ( {
8288 tsconfig : 'tsconfig.json' ,
8389 expectedAudits : [ ] ,
8490 } ) ;
85- await expect ( runner ( ( ) => void 0 ) ) . resolves . toStrictEqual ( [ ] ) ;
91+ expect ( runner ( runnerArgs ) ) . toStrictEqual ( [ ] ) ;
8692 expect ( getIssueFromDiagnosticSpy ) . toHaveBeenCalledTimes ( 1 ) ;
8793 expect ( getIssueFromDiagnosticSpy ) . toHaveBeenCalledWith (
8894 mockSemanticDiagnostic ,
8995 ) ;
9096 } ) ;
9197
92- it ( 'should return multiple issues per audit' , async ( ) => {
98+ it ( 'should return multiple issues per audit' , ( ) => {
9399 const code = 2222 ;
94- getTypeScriptDiagnosticsSpy . mockResolvedValue ( [
100+ getTypeScriptDiagnosticsSpy . mockReturnValue ( [
95101 mockSemanticDiagnostic ,
96102 {
97103 ...mockSemanticDiagnostic ,
@@ -104,7 +110,7 @@ describe('createRunnerFunction', () => {
104110 expectedAudits : [ { slug : 'semantic-errors' } ] ,
105111 } ) ;
106112
107- const auditOutputs = await runner ( ( ) => void 0 ) ;
113+ const auditOutputs = runner ( runnerArgs ) ;
108114 expect ( auditOutputs ) . toStrictEqual ( [
109115 {
110116 slug : 'semantic-errors' ,
@@ -126,8 +132,8 @@ describe('createRunnerFunction', () => {
126132 expect ( ( ) => auditOutputsSchema . parse ( auditOutputs ) ) . not . toThrow ( ) ;
127133 } ) ;
128134
129- it ( 'should return multiple audits' , async ( ) => {
130- getTypeScriptDiagnosticsSpy . mockResolvedValue ( [
135+ it ( 'should return multiple audits' , ( ) => {
136+ getTypeScriptDiagnosticsSpy . mockReturnValue ( [
131137 mockSyntacticDiagnostic ,
132138 mockSemanticDiagnostic ,
133139 ] ) ;
@@ -136,7 +142,7 @@ describe('createRunnerFunction', () => {
136142 expectedAudits : [ { slug : 'semantic-errors' } , { slug : 'syntax-errors' } ] ,
137143 } ) ;
138144
139- const auditOutputs = await runner ( ( ) => void 0 ) ;
145+ const auditOutputs = runner ( runnerArgs ) ;
140146 expect ( auditOutputs ) . toStrictEqual ( [
141147 expect . objectContaining ( {
142148 slug : 'semantic-errors' ,
@@ -159,8 +165,8 @@ describe('createRunnerFunction', () => {
159165 ] ) ;
160166 } ) ;
161167
162- it ( 'should return valid AuditOutput shape' , async ( ) => {
163- getTypeScriptDiagnosticsSpy . mockResolvedValue ( [
168+ it ( 'should return valid AuditOutput shape' , ( ) => {
169+ getTypeScriptDiagnosticsSpy . mockReturnValue ( [
164170 mockSyntacticDiagnostic ,
165171 {
166172 ...mockSyntacticDiagnostic ,
@@ -178,7 +184,7 @@ describe('createRunnerFunction', () => {
178184 tsconfig : 'tsconfig.json' ,
179185 expectedAudits : [ { slug : 'semantic-errors' } , { slug : 'syntax-errors' } ] ,
180186 } ) ;
181- const auditOutputs = await runner ( ( ) => void 0 ) ;
187+ const auditOutputs = runner ( runnerArgs ) ;
182188 expect ( ( ) => auditOutputsSchema . parse ( auditOutputs ) ) . not . toThrow ( ) ;
183189 } ) ;
184190} ) ;
0 commit comments