Screenshot Tests
Generate Paparazzi screenshot tests following project patterns.
Usage
code
/screenshot-tests MyScreenView.kt # Generate screen tests /screenshot-tests MyComponent.kt # Generate component tests
Two Modes
1. Screen Tests (:screens modules)
Test full screens with multiple ViewState variations:
kotlin
class MyScreenViewScreenshotTest {
@get:Rule
val paparazzi = paparazziScreenshotRule()
@Test
fun screenshots() {
PaparazziDeviceConfig.entries.forEach { device ->
MyViewStatePreviewProvider().values.forEach { state ->
paparazzi.snapshotScreen(
name = "device=${device.name}_state=${state.name}",
deviceConfig = device,
) {
JellyfinEdgeToEdgePreviewTheme {
MyView(state = state, onIntent = {})
}
}
}
}
}
}
2. Component Tests (:ui modules)
Test individual UI components with custom methods:
kotlin
class MyComponentScreenshotTest {
@get:Rule
val paparazzi = paparazziScreenshotRule()
@Test
fun `default state`() {
paparazzi.snapshotComponent {
JellyfinPreviewTheme {
MyComponent(text = "Hello")
}
}
}
@Test
fun `loading state`() {
paparazzi.snapshotComponent {
JellyfinPreviewTheme {
MyComponent(isLoading = true)
}
}
}
}
Key Patterns
- •Use ViewStatePreviewProvider for screens with multiple states
- •Test on multiple devices using
PaparazziDeviceConfig.entries - •Wrap content in proper theme (
JellyfinEdgeToEdgePreviewThemefor screens) - •Wrap Coil images in
JellyfinPreviewAsyncImageProviderif needed
Commands
bash
./gradlew verifyPaparazziDebug # Verify against golden images ./gradlew recordPaparazziDebug # Record new golden images
Process
- •Read the source file to understand component/screen structure
- •Check for existing PreviewProvider or preview functions
- •Generate test class following appropriate pattern
- •Run
./gradlew :module:verifyPaparazziDebugto verify - •Record if new:
./gradlew :module:recordPaparazziDebug