Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(browser) {
if (!browser) {
throw new Error('A WebdriverIO instance is needed to initialise percy-webdriverio');
}
browser.percy = { assetLoaders: [] };
const enabled = isEnabled();
const token = process.env.PERCY_TOKEN;
const apiUrl = process.env.PERCY_API;
const clientInfo = `percy-webdriverio ${version}`;
browser.percy.environment = new Environment(process.env);
browser.percy.percyClient = new PercyClient({ token, apiUrl, clientInfo });
// adding `async` as function name disables the synchronous behavior of WebdriverIO commands
// eslint-disable-next-line prefer-arrow-callback
browser.addCommand('__percyReinit', function async() {
browser.percy = { assetLoaders: [] };
browser.percy.environment = new Environment(process.env);
browser.percy.percyClient = new PercyClient({ token, apiUrl, clientInfo });
});
browser.addCommand('percyFinalizeBuild', () => {
throw new Error(
'[percy] browser.percyFinalizeBuild is deprecated, see https://github.com/percy/percy-webdriverio/pull/19',
);
});
browser.addCommand('__percyReinit', function async() {
browser.percy = { assetLoaders: [] };
browser.percy.environment = new Environment(process.env);
browser.percy.percyClient = new PercyClient({ token, apiUrl, clientInfo });
});