import { expect } from '@jest/globals' ; import type { Migration , MigrationConstructor , } from '../lib/config/migrations/types' ; import type { RenovateConfig } from '../lib/config/types' ; import { MigrationsService } from './../lib/config/migrations/migrations-service' ; declare global { namespace jest { interface Matchers < R > { toMigrate ( originalConfig , expectedConfig , isMigrated ? ) : R ; } } } expect . extend ( { toMigrate ( CustomMigration , originalConfig , expectedConfig , isMigrated = true ) { class CustomMigrationsService extends MigrationsService { protected static override getMigrations ( original , migrated ) { return [ new CustomMigration ( original , migrated ) ] ; } } const migratedConfig = CustomMigrationsService . run ( originalConfig ) ; if ( MigrationsService . isMigrated ( migratedConfig , originalConfig ) !== isMigrated ) { return { message : ( ) : string => `isMigrated should be ${ isMigrated }` , pass : false , } ; } if ( ! this . equals ( migratedConfig , expectedConfig ) ) { return { message : ( ) : string => 'Migration failed' , pass : false , } ; } return { message : ( ) : string => 'Migration passed successfully' , pass : true , } ; } , } ) ;