Repository: airbnb/lottie-ios
File: Tests/AnimationKeypathTests.swift (Swift)

Code before:
  /// All keypaths that are supported in the Core Animation engine should also be supported by the Main Thread engine.
  func testCoreAnimationEngineKeypathCompatibility() async {
    let mainThreadKeypaths =
      Set(await hierarchyKeypaths(animationName: "Switch", configuration: .init(renderingEngine: .mainThread)))
    let coreAnimationKeypaths = await hierarchyKeypaths(
      animationName: "Switch",
      configuration: .init(renderingEngine: .coreAnimation))

    for coreAnimationKeypath in coreAnimationKeypaths {
      XCTAssert(
        mainThreadKeypaths.contains(coreAnimationKeypath),
        """
        \(coreAnimationKeypath) from Core Animation rendering engine \
        is not supported in Main Thread rendering engine
        """)
    }
  }

  // MARK: Private

  private func snapshotHierarchyKeypaths(
    animationName: String,
    configuration: LottieConfiguration,
    function: String = #function,
    line: UInt = #line)
  async {
    let hierarchyKeypaths = await hierarchyKeypaths(animationName: animationName, configuration: configuration)

    assertSnapshot(
      matching: hierarchyKeypaths.sorted().joined(separator: "\n"),
      as: .description,
      named: animationName,
      testName: function,
      line: line)
  }

  private func hierarchyKeypaths(animationName: String, configuration: LottieConfiguration) async -> [String] {
    var printedMessages = [String]()
    let logger = LottieLogger(info: { message in
      printedMessages.append(message())
    })

    let animationView = await SnapshotConfiguration.makeAnimationView(
      for: animationName,
      configuration: configuration,
      logger: logger)
    animationView?.logHierarchyKeypaths()
    return Array(printedMessages[1...])
  }

}

Review comment (suggestion):
I was trying to figure out what was going on here for a while lol, but then just realized it was part of the method declaration
```suggestion
    async 
  {
```

Code after:
  /// All keypaths that are supported in the Core Animation engine should also be supported by the Main Thread engine.
  func testCoreAnimationEngineKeypathCompatibility() async {
    let mainThreadKeypaths =
      Set(await hierarchyKeypaths(animationName: "Switch", configuration: .init(renderingEngine: .mainThread)))
    let coreAnimationKeypaths = await hierarchyKeypaths(
      animationName: "Switch",
      configuration: .init(renderingEngine: .coreAnimation))

    for coreAnimationKeypath in coreAnimationKeypaths {
      XCTAssert(
        mainThreadKeypaths.contains(coreAnimationKeypath),
        """
        \(coreAnimationKeypath) from Core Animation rendering engine \
        is not supported in Main Thread rendering engine
        """)
    }
  }

  // MARK: Private

  private func snapshotHierarchyKeypaths(
    animationName: String,
    configuration: LottieConfiguration,
    function: String = #function,
    line: UInt = #line) async
  {
    let hierarchyKeypaths = await hierarchyKeypaths(animationName: animationName, configuration: configuration)

    assertSnapshot(
      matching: hierarchyKeypaths.sorted().joined(separator: "\n"),
      as: .description,
      named: animationName,
      testName: function,
      line: line)
  }

  private func hierarchyKeypaths(animationName: String, configuration: LottieConfiguration) async -> [String] {
    var printedMessages = [String]()
    let logger = LottieLogger(info: { message in
      printedMessages.append(message())
    })

    let animationView = await SnapshotConfiguration.makeAnimationView(
      for: animationName,
      configuration: configuration,
      logger: logger)
    animationView?.logHierarchyKeypaths()
    return Array(printedMessages[1...])
  }

}