diff --git a/generateImage.js b/generateImage.js index d12281f..daf4704 100755 --- a/generateImage.js +++ b/generateImage.js @@ -2,6 +2,14 @@ const puppeteer = require("puppeteer"); const merge = require("lodash.merge"); const debug = require("./debug"); +const addArg = (opts, arg) => { + if (!Array.isArray(opts.launchOptions.args)) opts.launchOptions.args = []; + + if (!opts.launchOptions.args.includes(arg)) { + opts.launchOptions.args.push(arg); + } +}; + const takeScreenshot = async (html, opts) => { // Options see: // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions @@ -42,6 +50,11 @@ const generateImage = async options => { opts.launchOptions.defaultViewport = options.viewport; } + // Disable "lcd text antialiasing" to avoid differences in the snapshots + // depending on the used monitor. + // See https://github.com/dferber90/jsdom-screenshot/issues/1 + addArg(opts, "--disable-lcd-text"); + // Allows easy debugging by passing generateImage({ debug: true }) if (opts.debug) debug(document);