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

Enhancement Request: Ability to Choose Output File Name and Path #963

Closed
rulogarcillan opened this issue Jun 29, 2023 · 6 comments
Closed
Labels
enhancement New feature or request

Comments

@rulogarcillan
Copy link

Dear Paparazzi Team,

I hope this message finds you well. I would like to express my appreciation for the excellent functionality provided by the Paparazzi library. It has been incredibly useful for generating screenshots of my composables within my own application.

However, I have encountered a limitation that is hindering my workflow. Currently, the output file name for the screenshots is automatically generated as "62e6827980591d8e5a895a63978f3df69b3fe968," despite the existence of a variable named "name." Additionally, I am unable to specify the desired path for saving these files.

While I understand that the library was initially designed for screenshot tests, I believe that enhancing it with the ability to choose the output file name and path would greatly expand its utility. Personally, my use case revolves around generating screenshots of components for various purposes within my application.

I kindly request that you consider implementing these enhancements in a future update of the Paparazzi library. I believe this would not only benefit me but also many other developers who could benefit from its extended functionality.

Thank you for your attention to this matter, and I look forward to your response.

Best regards,

@rulogarcillan rulogarcillan added the enhancement New feature or request label Jun 29, 2023
@martirius
Copy link

If you want to generate screenshots with names, you have to run the gradle task recordPaparazzi*yourBuildVariantHere*

@rulogarcillan
Copy link
Author

That generates a Golden screen, and the name is not customizable, it adds information that I don't want, it doesn't even give the option to choose the route. As I mentioned, my desire is not to test, but to generate documentation later with these screenshots, even generate images to later use them in other projects, that is why I use this library but not for its original purpose. hence the request that it evolve to more.

@TWiStErRob
Copy link
Contributor

TWiStErRob commented Jul 2, 2023

(I'm just a contributor here, don't know how much the team supports adding new features).

If I wanted to implement your requirements, I would break this down into smaller steps and try to utilise/request building blocks that might be useful for other things too. As you said "use this library but not for its original purpose", so it's hard for the library to specialise for this purpose. Here's a few points that might help achieving your end goal:

  • record, as @martirius mentioned creates named files, instead of hashes, so the names are possible to "customize"
  • Renaming a file: the name corresponds to the test name as far as I know, and in Kotlin we can use backticks, so it's possible to name the output file pretty close to anything. Related Feature Request: Provide a way of simplifying snapshot name #549
  • structure: you can create arbitrary modules or use JUnit test filters to group tests (generated images) together.
  • Using images in other places: having a different name than you exactly expect shouldn't be a big problem, it's very easy to bulk rename/move files on the file system with globs and UNIX utils/Gradle tasks. Compare it to parsing a JSON from a third party: we wouldn't expect exactly the format/object graph we need, but we convert it to a domain representation we want.
  • Choosing a route (assume you meant output folder): there's a PR for making it configurable, but as noted in previous point, moving files should be easy outside the scope of Paparazzi. Additionally as comment below suggested you can relocate output via custom SnapshotVerifier/HtmlReportWriter

See also #973, which might be an interesting building block/alternative.

@apkelly
Copy link

apkelly commented Jul 10, 2023

This doesn't solve the filename problem, but we customise the location of the images using this code.

    companion object {
        private val isVerifying: Boolean =
            System.getProperty("paparazzi.test.verify")?.toBoolean() == true

        // Place images in flavor specific sub-folders.
        val snapshotHandler = if (isVerifying) {
            SnapshotVerifier(
                maxPercentDifference = 0.1,
                rootDirectory = File("src/test/snapshots/${BuildConfig.FLAVOR_customer}")
            )
        } else {
            HtmlReportWriter(
                snapshotRootDirectory = File("src/test/snapshots/${BuildConfig.FLAVOR_customer}")
            )
        }
    }

    @get:Rule
    val paparazzi = Paparazzi(
        deviceConfig = PIXEL_5,
        snapshotHandler = snapshotHandler,
        theme = "android:Theme.Material.Light.NoActionBar"
    )

@apkelly
Copy link

apkelly commented Jul 10, 2023

If you want to change the filename, give this issue a +1 #549 (comment)

@jrodbx
Copy link
Collaborator

jrodbx commented Jan 19, 2024

Closing as duplicate of #549

@jrodbx jrodbx closed this as completed Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants