diff --git a/.gitignore b/.gitignore index ec1fc5d..01eabac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules geckodriver.log .nyc_output +logs/ diff --git a/commands/percySnapshot.js b/commands/percySnapshot.js index 391551b..20b9f36 100644 --- a/commands/percySnapshot.js +++ b/commands/percySnapshot.js @@ -19,15 +19,18 @@ module.exports = class PercySnapshotCommand { // Serialize and capture the DOM /* istanbul ignore next: no instrumenting injected code */ - let { value: { domSnapshot, url } } = ( - await this.api.execute(function(options) { + let { domSnapshot, url } = await new Promise((resolve) => { + this.api.execute(function(options) { return { /* eslint-disable-next-line no-undef */ domSnapshot: PercyDOM.serialize(options), url: document.URL }; - }, [options]) - ); + }, [options], function(result) { + // Check if we're in Nightwatch 1.x (which returns with `.value`) + result.value ? resolve(result.value) : resolve(result); + }); + }); // Post the DOM to the snapshot endpoint with snapshot options and other info await utils.postSnapshot({ diff --git a/package.json b/package.json index ca64ac9..8d4058d 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@percy/sdk-utils": "^1.0.0" }, "peerDependencies": { - "nightwatch": "~1" + "nightwatch": ">=1" }, "devDependencies": { "@percy/core": "^1.0.0",