File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -136,4 +136,60 @@ describe('coreConfigSchema', () => {
136136 'category references need to point to an audit or group: eslint#eslint-errors (group)' ,
137137 ) ;
138138 } ) ;
139+
140+ it ( 'should throw for a category with a zero-weight audit' , ( ) => {
141+ const config = {
142+ categories : [
143+ {
144+ slug : 'performance' ,
145+ title : 'Performance' ,
146+ refs : [
147+ {
148+ slug : 'performance' ,
149+ weight : 1 ,
150+ type : 'group' ,
151+ plugin : 'lighthouse' ,
152+ } ,
153+ ] ,
154+ } ,
155+ {
156+ slug : 'best-practices' ,
157+ title : 'Best practices' ,
158+ refs : [
159+ {
160+ slug : 'best-practices' ,
161+ weight : 1 ,
162+ type : 'group' ,
163+ plugin : 'lighthouse' ,
164+ } ,
165+ ] ,
166+ } ,
167+ ] ,
168+ plugins : [
169+ {
170+ slug : 'lighthouse' ,
171+ title : 'Lighthouse' ,
172+ icon : 'lighthouse' ,
173+ runner : { command : 'npm run lint' , outputFile : 'output.json' } ,
174+ audits : [
175+ {
176+ slug : 'csp-xss' ,
177+ title : 'Ensure CSP is effective against XSS attacks' ,
178+ } ,
179+ ] ,
180+ groups : [
181+ {
182+ slug : 'best-practices' ,
183+ title : 'Best practices' ,
184+ refs : [ { slug : 'csp-xss' , weight : 0 } ] ,
185+ } ,
186+ ] ,
187+ } ,
188+ ] ,
189+ } satisfies CoreConfig ;
190+
191+ expect ( ( ) => coreConfigSchema . parse ( config ) ) . toThrow (
192+ 'In a category, there has to be at least one ref with weight > 0. Affected refs: csp-xss' ,
193+ ) ;
194+ } ) ;
139195} ) ;
You can’t perform that action at this time.
0 commit comments