visreg-test
Version:
A visual regression testing solution that offers an easy setup with simple yet powerful customisation options, wrapped up in a convenient CLI runner to make assessing and accepting/rejecting diffs a breeze.
45 lines (44 loc) • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const cypress_1 = require("cypress");
const plugin_1 = require("cypress-image-snapshot-fork-2/plugin");
const util_1 = require("util");
const shared_1 = require("./shared");
exports.default = (0, cypress_1.defineConfig)({
e2e: Object.assign(Object.assign({ specPattern: shared_1.suitesDirectory + '/**/snaps.{js,ts}', supportFile: false, responseTimeout: 60000, screenshotOnRunFailure: false }, shared_1.timeouts), { setupNodeEvents(on, config) {
on('before:browser:launch', (browser, launchOptions) => {
const width = shared_1.maxViewportWidth;
const height = shared_1.maxViewportHeight;
if (browser.name === 'chrome' && browser.isHeadless) {
launchOptions.args.push(`--window-size=${width},${height}`);
launchOptions.args.push('--disable-smooth-scrolling'); // potentially alleviates some issues with scroll behavior
}
if (browser.name === 'electron' && browser.isHeadless) {
// might not work on CI for some reason
launchOptions.preferences.width = width;
launchOptions.preferences.height = height;
}
if (browser.name === 'firefox' && browser.isHeadless) {
launchOptions.args.push(`--width=${width}`);
launchOptions.args.push(`--height=${height}`);
}
return launchOptions;
});
on('task', {
log(messages) {
const sanitizeMessages = messages.map((message) => {
return typeof message === 'object'
? (0, util_1.inspect)(message, {
showHidden: false,
depth: null,
colors: false
})
: message;
});
console.log(...sanitizeMessages);
return null;
}
});
(0, plugin_1.addMatchImageSnapshotPlugin)(on);
} }),
});