@wdio/visual-service
Version:
Image comparison / visual regression testing for WebdriverIO
22 lines (21 loc) • 844 B
JavaScript
import { getInstanceData } from './utils.js';
/**
* Wrap the command with the context manager
* This will make sure that the context manager is updated when needed
* and that the command is executed in the correct context
*/
export function wrapWithContext(opts) {
const { browserInstance, command, contextManager, getArgs } = opts;
return async function () {
if (contextManager.needsUpdate) {
const instanceData = await getInstanceData({
browserInstance,
initialDeviceRectangles: contextManager.getViewportContext(),
isNativeContext: contextManager.isNativeContext,
});
contextManager.setViewPortContext(instanceData.deviceRectangles);
}
const finalArgs = getArgs();
return command.apply(this, finalArgs);
};
}