Add support for Compose Preview Screenshot Testing
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 3.2k
- Forks
- 106
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
https://github.com/dfabulich/skipapp-compose-snapshot-sample
This is a Skip Lite dual-platform app project, written mostly in Swift that transpiles to Kotlin, demonstrating how to setup and run Compose Preview Screenshot Testing.
What's Compose Preview Screenshot Testing?
In Compose Preview Screenshot Testing, you write
@Previewcomponents (like SwiftUI#Preview, but in Jetpack Compose) and decorate them with@PreviewTest. Anupdatebuild plugin captures screenshots of all of your@PreviewTestcomponents and writes them to disk; you commit them with your code.Later, you run your tests again in
validatemode. The tests fail if any of your components render differently. You then review the updated screenshots in a generate HTML report; if you approve of all of the changes, rerunupdate, which wil regenerate all of the snapshots.![]()
Writing a test
@PreviewTest @Preview(showBackground = true) @Composable fun WelcomeViewPreview() { ProcessInfo.launch(LocalContext.current) Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { WelcomeView(welcomeName = Binding.constant("Skipper")) .Compose(context = ComposeContext()) } }Running tests
Generate screenshot test results:
gradle -p Android -Pandroid.experimental.enableScreenshotTest=true updateDebugScreenshotTestValidate that screenshot test results are unchanged:
gradle -p Android -Pandroid.experimental.enableScreenshotTest=true valdateDebugScreenshotTest(We have to use
-Pbecause setting this inAndroid/app/gradle.propertieschange doesn't apply to all of the projects that Skip generates; see below.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked skipapp-compose-snapshot-sample and compare its Android project with the generated project behavior. Read Android/app/gradle.properties and run the documented updateDebugScreenshotTest and valdateDebugScreenshotTest commands to understand the required integration. Done means Skip-generated projects can configure and run Compose Preview Screenshot Testing consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- build-system, mobile-dev, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100