loki icon indicating copy to clipboard operation
loki copied to clipboard

Is there no way to detect which simulator the screenshot came from?

Open kumarpatel opened this issue 3 years ago • 4 comments

I love this solution sooo much. It's so fast to run making it almost difficult to justify not using it.

It even runs on multiple simulators open at the same time. incredible. it just doesn't have the device names on each of the screenshots.

I'm fairly certain this issue was described in Roadmap issue But thought I'd check in to see if there's any new updates/developments in this space that can make this possible. https://github.com/wix-incubator/rnsst seems to be trying to solve similar problems using Detox @oblador @techeverri

kumarpatel avatar Sep 14 '21 16:09 kumarpatel

@lpatrun I made some progress, but it's kind of silly and weird.

This works as I would expect.

  • Opens the simulators I have defined in my detox.config.json one after the other. (or I can run my test against a specific iOS simulator version)
  • Installs the app (I added logic in my entry file to open StorybookUI depending on env var)
  • Detox runs through all stories and takes screenshots and saves them in the appropriate dir; i.e. reference/ios/iphone-12, current/ios/iphone-12
  • Then I manually run above mentioned reg-cli script with minor modification to do the diffing as well.

This, by its very nature, is slower than loki because it has to spin up, install app and spin down the device. It's hands-off and so much faster than any e2e test suit, that I might just end up using this frankenstein's monster version of this setup.

I'm conflicted here because loki, the way it functions right now, is so much faster for my development workflow that I prefer it over anything else. But there's a point in my workflow right before I push something up for review, I want to test on other devices 😭 and I think I would prefer using this, slightly slower, detox solution in this case

kumarpatel avatar Sep 16 '21 21:09 kumarpatel

It even runs on multiple simulators open at the same time. incredible. it just doesn't have the device names on each of the screenshots.

I don't really know what you mean by “device names on each of the screenshots” Providing an example of the scenario and the expected behavior helps everyone to understand

In any case, you can do a lot of things to personalize the name of the files generated by Loki Check the official docs on the fileNameFormatter function 👇 🔗 https://loki.js.org/configuration.html#filenameformatter

https://github.com/oblador/loki/blob/8beda16fcda4841c4e23c7353880e94498cbadcc/packages/runner/src/commands/test/get-output-paths.js#L9-L10

By default, it produces files with names similar to the ones in the screenshot below 👇 🔗 https://github.com/oblador/loki/tree/master/examples/react/.loki/reference image

techeverri avatar Sep 19 '21 00:09 techeverri

@techeverri thank you

lpatrun avatar Sep 19 '21 10:09 lpatrun

@techeverri Upon looking into it further, you are correct. It is adding the device names (based on my configuration object) on screenshot files. Here's my scenario and the outcome. Maybe you can help me figure out what exactly is the problem here.

The scenario, (see attached screenshots)

  • I have a single Story that displays the device name using react-native-device-info lib
  • Open iPhone 12 simulator. Launch app with Storybook initialized.
  • Open iPhone SE simulator. Launch app with Storybook initialized.
  • Run loki update
  • This generates 2 files with correct names. (seems promising)
    • ios_iphone12_DemoScreen_Behaviour.png
    • ios_iphoneSE_DemoScreen_Behaviour.png
  • The images captured though are from the same simulator, iPhone 12. Even though both simulators we cycling through stories when loki was running.

The issue seems to be that the screenshot captured isn't actually from the simulator the filename claims it was captured from.

Screen Shot 2021-09-23 at 6 05 47 PM

Here's what the simulators actually rendered. Screen Shot 2021-09-23 at 6 25 02 PM

kumarpatel avatar Sep 23 '21 21:09 kumarpatel