From 66bc6d523509e6da689ab78d409020da61fa283e Mon Sep 17 00:00:00 2001 From: Dominik Ferber Date: Sun, 23 Sep 2018 10:34:53 +0200 Subject: [PATCH] fix: disable lcd text closes #1 --- generateImage.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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);