Skip to content

Commit

Permalink
fix: require the SDK utils directly (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
djones committed Apr 6, 2019
2 parents 689f461 + d63d707 commit 25d3b3e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs'
import { clientInfo } from './environment'
import { agentJsFilename, isAgentRunning, postSnapshot } from '@percy/agent'
const { agentJsFilename, isAgentRunning, postSnapshot } = require('@percy/agent/dist/utils/sdk-utils')

declare var PercyAgent: any;
declare var PercyAgent: any

/**
* @param browser wdio Browser object that we are snapshotting. Required.
Expand All @@ -23,9 +23,9 @@ export async function percySnapshot(browser: BrowserObject, name: string, option

await browser.executeScript(fs.readFileSync(agentJsFilename()).toString(), [])

const domSnapshot = await browser.execute(function (options: any) {
const percyAgentClient = new PercyAgent({ handleAgentCommunication: false });
return percyAgentClient.snapshot("unused", options);
const domSnapshot = await browser.execute((options: any) => {
const percyAgentClient = new PercyAgent({ handleAgentCommunication: false })
return percyAgentClient.snapshot('unused', options)
}, options)

await postDomSnapshot(name, domSnapshot, await browser.getUrl(), options)
Expand All @@ -37,9 +37,9 @@ async function postDomSnapshot(name: string, domSnapshot: any, url: string, opti
url,
domSnapshot,
clientInfo: clientInfo(),
...options
...options,
})
if (!postSuccess) {
console.log(`[percy] Error posting snapshot to agent`)
console.log('[percy] Error posting snapshot to agent')
}
}

0 comments on commit 25d3b3e

Please sign in to comment.