mergedMocksFor static method

Future<TestMocks> mergedMocksFor({
  1. required String assetPath,
  2. List<String> suiteMockFiles = const [],
  3. Map<String, dynamic> suiteInlineMocks = const {},
  4. required List<String> mockFiles,
  5. required Map<String, dynamic> inlineMocks,
  6. required AssetStringLoader assetLoader,
})

Implementation

static Future<TestMocks> mergedMocksFor({
  required String assetPath,
  List<String> suiteMockFiles = const [],
  Map<String, dynamic> suiteInlineMocks = const {},
  required List<String> mockFiles,
  required Map<String, dynamic> inlineMocks,
  required AssetStringLoader assetLoader,
}) async {
  final raw = <String, Map<String, dynamic>>{};
  for (final file in suiteMockFiles) {
    await _mergeMockFile(
      into: raw,
      fromAssetPath: assetPath,
      mockFilePath: file,
      assetLoader: assetLoader,
    );
  }
  await _mergeInlineMocks(
    into: raw,
    inlineMocks: suiteInlineMocks,
    sourceLabel: 'tests/config.yaml',
    fromAssetPath: assetPath,
    assetLoader: assetLoader,
  );
  for (final file in mockFiles) {
    await _mergeMockFile(
      into: raw,
      fromAssetPath: assetPath,
      mockFilePath: file,
      assetLoader: assetLoader,
    );
  }
  await _mergeInlineMocks(
    into: raw,
    inlineMocks: inlineMocks,
    sourceLabel: assetPath,
    fromAssetPath: assetPath,
    assetLoader: assetLoader,
  );
  return TestMocks(
    apis: MockComposition.toMockApis(raw, sourceLabel: assetPath),
  );
}