diff --git a/.travis.yml b/.travis.yml index c576a02..19d3e7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: node_js node_js: - - "8" - "6" + - "8" + - "9" diff --git a/package.json b/package.json index 34521da..21d5b04 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "lodash": "^4.17.4", "mkdirp": "^0.5.1", "pixelmatch": "^4.0.2", - "pngjs": "^3.3.0", + "pngjs": "^3.3.3", "rimraf": "^2.6.2" }, "peerDependencies": { diff --git a/src/diff-snapshot.js b/src/diff-snapshot.js index 687bcf8..3ac57b9 100644 --- a/src/diff-snapshot.js +++ b/src/diff-snapshot.js @@ -156,9 +156,12 @@ function diffImageToSnapshot(options) { ); const input = { imagePath: diffOutputPath, image: compositeResultImage }; + // image._packer property contains a circular reference since node9, causing JSON.stringify to + // fail. Might as well discard all the hidden properties. + const serializedInput = JSON.stringify(input, (name, val) => (name[0] === '_' ? undefined : val)); // writing diff in separate process to avoid perf issues associated with Math in Jest VM (https://github.com/facebook/jest/issues/5163) - const writeDiffProcess = childProcess.spawnSync('node', [`${__dirname}/write-result-diff-image.js`], { input: Buffer.from(JSON.stringify(input)) }); + const writeDiffProcess = childProcess.spawnSync('node', [`${__dirname}/write-result-diff-image.js`], { input: Buffer.from(serializedInput) }); // in case of error print to console if (writeDiffProcess.stderr.toString()) { console.log(writeDiffProcess.stderr.toString()); } // eslint-disable-line no-console, max-len }