writeResponseData function

Future<void> writeResponseData (
  1. Map<String, dynamic> data,
  2. {String testOutputFilename: 'integration_response_data',
  3. String destinationDirectory}
)

Writes a json-serializable json data to to testOutputsDirectory/testOutputFilename.json.

This is the default responseDataCallback in integrationDriver.

Implementation

Future<void> writeResponseData(
  Map<String, dynamic> data, {
  String testOutputFilename = 'integration_response_data',
  String destinationDirectory,
}) async {
  assert(testOutputFilename != null);
  destinationDirectory ??= testOutputsDirectory;
  await fs.directory(destinationDirectory).create(recursive: true);
  final File file = fs.file(path.join(
    destinationDirectory,
    '$testOutputFilename.json',
  ));
  final String resultString = _encodeJson(data, true);
  await file.writeAsString(resultString);
}