loki icon indicating copy to clipboard operation
loki copied to clipboard

React native for android, screenshots taken very fast

Open mowbell opened this issue 6 years ago • 0 comments

I suggest to change implementation for android, screenshots are taken early.

Due that Android emulator rendering is slow (frecuently), sometimes screenshots are taken from previous stories. Sometime behavior is unpredictable, yet overriding some stuff like timeouts and requestAnimationFrame to prevent flaky test like is suggested on docs

(Maybe to add some delay between story changes or for screenshot captures)

targets/native/android-emulator.js

const osnap = require('osnap/src/android');
const createWebsocketTarget = require('./create-websocket-target');
const { withTimeout } = require('../../failure-handling');

const saveScreenshotToFile = async filename =>
  new Promise((resolve) => {
    setTimeout(() => {
      osnap.saveToFile({ filename });
      resolve();
    }, 3000);
  });
const createAndroidEmulatorTarget = socketUri =>
  createWebsocketTarget(socketUri, 'android', saveScreenshotToFile);

module.exports = createAndroidEmulatorTarget;

Also for future, Will be good to add new command line or configuration flags for customize delays implemented on code (I'll think to contribute for it, in near future)

mowbell avatar Jan 09 '19 20:01 mowbell