Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snapshots] Add lottie executor to avoid issues with Lottie flakes #287

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ kotlinx-serialization = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"

ktor-network = { module = "io.ktor:ktor-network", version = "2.1.1" }

lottie = { module = "com.airbnb.android:lottie", version = "6.5.2" }

mockito = { module = "org.mockito:mockito-inline", version.ref = "mockito" }
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito" }

Expand Down
1 change: 1 addition & 0 deletions snapshots/snapshots/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ dependencies {
api(libs.androidx.test.rules)
api(libs.androidx.test.runner)
api(libs.compose.ui.test.junit)
api(libs.lottie)

testImplementation(libs.junit)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import android.util.Log
import androidx.compose.ui.tooling.PreviewActivity
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.platform.app.InstrumentationRegistry
import com.airbnb.lottie.LottieTask
import com.emergetools.snapshots.EmergeSnapshots
import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig
import com.emergetools.snapshots.shared.ComposeSnapshots
import kotlinx.serialization.json.Json
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.io.File
import java.util.concurrent.Executor

@RunWith(Parameterized::class)
class EmergeComposeSnapshotReflectiveParameterizedInvoker(
Expand Down Expand Up @@ -79,6 +82,12 @@ class EmergeComposeSnapshotReflectiveParameterizedInvoker(
@get:Rule
val snapshotRule: EmergeSnapshots = EmergeSnapshots()

@Before
fun setup() {
// https://github.com/cashapp/paparazzi/issues/630#issuecomment-1512516656
LottieTask.EXECUTOR = Executor(Runnable::run)
}

@Test
fun reflectiveComposableInvoker() {
Log.i(TAG, "Running snapshot test ${parameter.previewConfig.keyName()}")
Expand Down
Loading