Is it possible to assert Snapshot in between TestStore .send and .receive asserts?

Hi,

Is there a way to do SnapshotTesting by using the .do function when asserting on the TestStore in between .send and .receive ?

    testStore.assert([
      .do { assertSnapshot(matching: view, as: .windowedImage, named: "initialState") },
      .send(.mapContainer(.mapView(.locationManager(.didUpdateLocations([parisLocation]))))) {
        $0.mapContainer.mapView.userLocationCoordinate = parisLocation
      },
      .receive(.mapContainer(.mapView(.centerOnUserReceived))) {
        $0.mapContainer.mapView.mapCenter = parisLocation.coordinate
      },
      .do { assertSnapshot(matching: view, as: .windowedImage, named: "afterDidUpdateLocations(\(parisLocation)") },
      .send(.mapContainer(.floatingButtonView(.searchAgainTapped))),
      .receive(.refreshItemsFromMapCoordsReceived),
      .receive(.overlayContainer(.overlayLocal(.updateLevelReceived(.minimum)))),
      .receive(.mapContainer(.floatingButtonView(.hideSearchAgainReceived(true)))),
      .receive(.overlayContainer(.overlayLocal(.refreshPositionReceived))) {
        $0.overlayContainer.overlayLocal.position.height = -60
      },
      .do { assertSnapshot(matching: view, as: .windowedImage, named: "afterSearchAgainTapped") },
      .send(.mapContainer(.mapView(.userTappedPOI(selectedPro)))) {
        $0.selectedPro = selectedPro
        $0.content = .fd
      },
      .receive(.overlayContainer(.overlayLocal(.updateLevelReceived(.half)))) {
        $0.overlayContainer.overlayLocal.level = .half
      },
      .receive(.mapContainer(.mapView(.centerOnSelectedProReceived))) {
        $0.mapContainer.mapView.mapCenter = selectedPro?.coordinates
      },
      .receive(.overlayContainer(.overlayLocal(.refreshPositionReceived))) {
        $0.overlayContainer.overlayLocal.position.height = 0
      },
      .do { assertSnapshot(matching: view, as: .windowedImage, named: "afterUserTappedPOI\(selectedPro)") },
    ])

For this to work we need TestStore to provide a way to return a proper Store and feed TestStore to the View.

Terms of Service

Privacy Policy

Cookie Policy