Currently using the Compose Preview Screenshot Testing
library successfully to a certain degree.
The version I am currently using is 0.0.1-alpha08
The app is a multi-modular app with the following module structure:
:app
simply launches the feature screens:feature:chat
contains the full feature code, including composables and respective previews
feature\chat\src\screenshotTest\...\PreviewScreenshotCode.kt
:core
contains files used to display rich content in previews, such as json
and text
files which are read through context.resources.assets.open(...)
To recap: all normal (non-screenshot code) previews in :feature:chat
work perfectly fine, and they do display all the data pulled from :core
to used in the UI without any issues.
The screenshots taken by the library are also working almost fine, except that any data they need to use from :core
is never used, it's like it does not exist at all.
I have a suspicion that this might be related to different context environments between the code running in screenshotTest
vs what is available in :core
assets folder, maybe these files cannot be accessed from the context of a screenshotTestImplementation
so for all intents there are no files to read as a result.
I tried exploring multiple different ways to work around this, to use core test libraries to explicitly change the context used, but with no success.
Plan A:
Is there a way to make the screenshot library able to access the assets from the other module?
Plan B:
Less ideal, but would be acceptable. Is there a way that I can automatically generate a structured Object.kt
file that contains the contents of all json
or text
files located inside the assets folder so it can be directly accessed without having to use context? These would have to be automatically generated based on the files and their contents because they are numerous, and the manual process would be prohibitive.