parseDecodedDocument static method

EnsembleTestCase parseDecodedDocument(
  1. dynamic doc, {
  2. String? sourcePath,
  3. Map<String, dynamic> inputs = const {},
  4. Map<String, dynamic> scenario = const {},
  5. String? scenarioId,
  6. List<TestScenario>? parsedScenarios,
})

Parses a previously decoded document, validating its root before use. This lets selection and expansion share the same decoded tree even when service substitution changes the source text.

Implementation

static EnsembleTestCase parseDecodedDocument(
  dynamic doc, {
  String? sourcePath,
  Map<String, dynamic> inputs = const {},
  Map<String, dynamic> scenario = const {},
  String? scenarioId,
  List<TestScenario>? parsedScenarios,
}) {
  if (doc is! YamlMap) {
    throw EnsembleTestFailure(
        'Invalid test file${sourcePath != null ? ' ($sourcePath)' : ''}: root must be a map');
  }
  if (doc.containsKey('tests')) {
    throw EnsembleTestFailure(
      'Each *.test.yaml file defines one test at the root — remove the "tests" '
      'wrapper and put id, startScreen, and steps at the top level.',
    );
  }

  return _parseTestCase(
    doc,
    sourcePath: sourcePath,
    inputs: inputs,
    scenario: scenario,
    scenarioId: scenarioId,
    parsedScenarios: parsedScenarios,
  );
}