1
- import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest' ;
1
+ import { describe , expect , it } from 'vitest' ;
2
2
import { type Audit , categoryRefSchema } from '@code-pushup/models' ;
3
+ import { ui } from '@code-pushup/utils' ;
3
4
import { AUDITS } from './constants.js' ;
4
5
import {
5
6
filterAuditsByCompilerOptions ,
@@ -99,31 +100,21 @@ describe('getCategoryRefsFromGroups', () => {
99
100
100
101
it ( 'should return all groups as categoryRefs if compiler options are given' , async ( ) => {
101
102
const categoryRefs = await getCategoryRefsFromGroups ( {
102
- tsConfigPath : 'tsconfig.json' ,
103
+ tsconfig : 'tsconfig.json' ,
103
104
} ) ;
104
105
expect ( categoryRefs ) . toHaveLength ( 3 ) ;
105
106
} ) ;
106
107
107
108
it ( 'should return a subset of all groups as categoryRefs if compiler options contain onlyAudits filter' , async ( ) => {
108
109
const categoryRefs = await getCategoryRefsFromGroups ( {
109
- tsConfigPath : 'tsconfig.json' ,
110
+ tsconfig : 'tsconfig.json' ,
110
111
onlyAudits : [ 'semantic-errors' ] ,
111
112
} ) ;
112
113
expect ( categoryRefs ) . toHaveLength ( 1 ) ;
113
114
} ) ;
114
115
} ) ;
115
116
116
117
describe ( 'logSkippedAudits' , ( ) => {
117
- beforeEach ( ( ) => {
118
- vi . mock ( 'console' , ( ) => ( {
119
- warn : vi . fn ( ) ,
120
- } ) ) ;
121
- } ) ;
122
-
123
- afterEach ( ( ) => {
124
- vi . restoreAllMocks ( ) ;
125
- } ) ;
126
-
127
118
it ( 'should not warn when all audits are included' , ( ) => {
128
119
logSkippedAudits ( AUDITS ) ;
129
120
@@ -133,18 +124,15 @@ describe('logSkippedAudits', () => {
133
124
it ( 'should warn about skipped audits' , ( ) => {
134
125
logSkippedAudits ( AUDITS . slice ( 0 , - 1 ) ) ;
135
126
136
- expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
137
- expect ( console . warn ) . toHaveBeenCalledWith (
127
+ expect ( ui ( ) ) . toHaveLogged (
128
+ 'info' ,
138
129
expect . stringContaining ( `Skipped audits: [` ) ,
139
130
) ;
140
131
} ) ;
141
132
142
133
it ( 'should camel case the slugs in the audit message' , ( ) => {
143
134
logSkippedAudits ( AUDITS . slice ( 0 , - 1 ) ) ;
144
135
145
- expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
146
- expect ( console . warn ) . toHaveBeenCalledWith (
147
- expect . stringContaining ( `unknownCodes` ) ,
148
- ) ;
136
+ expect ( ui ( ) ) . toHaveLogged ( 'info' , expect . stringContaining ( `unknownCodes` ) ) ;
149
137
} ) ;
150
138
} ) ;
0 commit comments