'Flutter how to test Either<Failure,List<Object>>

it seems to have the same value with matcher but still can't pass the test probably cuz of the memory address stuff. can anyone let me know how i can test the result when a list is in Either<< Right >>

test('get board list from remote data source', () async {
   when(mockBoardRemoteDataSource.getBoards())
       .thenAnswer((_) async => tBoardModels);

   final result = await repository.getBoards();

   verify(mockBoardRemoteDataSource.getBoards());
   expect(result, equals(Right(toBoards)));   
   // Either<Failure, List<BoardInfo>> result;
   // (new) Right<dynamic, List<BoardInfo>> Right(List<BoardInfo> _r)
});

//console result

Expected: Right<dynamic, List<BoardInfo>>:<Right([_$_BoardInfo(1, name1, address1), _$_BoardInfo(2, name2, address2)])>
Actual: Right<Failure, List<BoardInfo>>:<Right([_$_BoardInfo(1, name1, address1), _$_BoardInfo(2, name2, address2)])>
    
package:test_api                                                                   expect
package:flutter_test/src/widget_tester.dart 455:16                                 expect
test\features\nurban_honey\data\repositories\board_repository_impl_test.dart 58:9  main.<fn>.<fn>.<fn>

//BoardInfo Implementation

import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'board_info.freezed.dart';

@freezed
class BoardInfo extends Equatable with _$BoardInfo {
  BoardInfo._();
  factory BoardInfo(int id, String name, String address) = _BoardInfo;

  @override
  List<Object?> get props => [id, name, address];
}


Solution 1:[1]

I've made the test pass by doing this:

result.fold(
       (l) => null,
       (resultR) => Right(toBoards)
           .fold((l) => null, (matcherR) => expect(resultR, matcherR)));

is there better way to do it?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jay