@@ -2,7 +2,11 @@ import { vol } from 'memfs';
22import type { PackageJson } from 'type-fest' ;
33import { MEMFS_VOLUME } from '@code-pushup/test-utils' ;
44import * as utils from '@code-pushup/utils' ;
5- import type { MonorepoHandlerOptions , ProjectConfig } from '../tools' ;
5+ import type {
6+ MonorepoHandlerOptions ,
7+ MonorepoHandlerProjectsContext ,
8+ ProjectConfig ,
9+ } from '../tools' ;
610import { yarnHandler } from './yarn' ;
711
812describe ( 'yarnHandler' , ( ) => {
@@ -171,6 +175,14 @@ describe('yarnHandler', () => {
171175 } ) ;
172176
173177 describe ( 'createRunManyCommand' , ( ) => {
178+ const projects : MonorepoHandlerProjectsContext = {
179+ all : [
180+ { name : 'api' , bin : 'yarn workspace api run code-pushup' } ,
181+ { name : 'cms' , bin : 'yarn workspace cms run code-pushup' } ,
182+ { name : 'web' , bin : 'yarn workspace web run code-pushup' } ,
183+ ] ,
184+ } ;
185+
174186 // eslint-disable-next-line vitest/max-nested-describe
175187 describe ( 'classic Yarn (v1)' , ( ) => {
176188 beforeEach ( ( ) => {
@@ -180,9 +192,9 @@ describe('yarnHandler', () => {
180192 } ) ;
181193
182194 it ( 'should run script for all workspaces sequentially' , async ( ) => {
183- await expect ( yarnHandler . createRunManyCommand ( options ) ) . resolves . toBe (
184- 'yarn workspaces run code-pushup' ,
185- ) ;
195+ await expect (
196+ yarnHandler . createRunManyCommand ( options , projects ) ,
197+ ) . resolves . toBe ( 'yarn workspaces run code-pushup' ) ;
186198 } ) ;
187199 } ) ;
188200
@@ -195,30 +207,39 @@ describe('yarnHandler', () => {
195207 } ) ;
196208
197209 it ( 'should run script for all workspaces sequentially by default' , async ( ) => {
198- await expect ( yarnHandler . createRunManyCommand ( options ) ) . resolves . toBe (
199- 'yarn workspaces foreach --all code-pushup' ,
200- ) ;
210+ await expect (
211+ yarnHandler . createRunManyCommand ( options , projects ) ,
212+ ) . resolves . toBe ( 'yarn workspaces foreach --all code-pushup' ) ;
201213 } ) ;
202214
203215 it ( 'should set parallel flag with default number of jobs' , async ( ) => {
204216 await expect (
205- yarnHandler . createRunManyCommand ( { ...options , parallel : true } ) ,
217+ yarnHandler . createRunManyCommand (
218+ { ...options , parallel : true } ,
219+ projects ,
220+ ) ,
206221 ) . resolves . toBe ( 'yarn workspaces foreach --parallel --all code-pushup' ) ;
207222 } ) ;
208223
209224 it ( 'should set parallel flag with custom number of jobs' , async ( ) => {
210225 await expect (
211- yarnHandler . createRunManyCommand ( { ...options , parallel : 5 } ) ,
226+ yarnHandler . createRunManyCommand (
227+ { ...options , parallel : 5 } ,
228+ projects ,
229+ ) ,
212230 ) . resolves . toBe (
213231 'yarn workspaces foreach --parallel --jobs=5 --all code-pushup' ,
214232 ) ;
215233 } ) ;
216234
217235 it ( 'should filter workspaces by list of project names' , async ( ) => {
218236 await expect (
219- yarnHandler . createRunManyCommand ( options , [ 'core' , 'utils' ] ) ,
237+ yarnHandler . createRunManyCommand ( options , {
238+ ...projects ,
239+ only : [ 'api' , 'cms' ] ,
240+ } ) ,
220241 ) . resolves . toBe (
221- 'yarn workspaces foreach --include=core --include=utils code-pushup' ,
242+ 'yarn workspaces foreach --include=api --include=cms code-pushup' ,
222243 ) ;
223244 } ) ;
224245 } ) ;
0 commit comments