UNPKG

dce-selenium

Version:

Selenium library to simplify testing and automatically snapshot the DOM.

18 lines (15 loc) 450 B
const fs = require('fs'); const getSnapshotFilenamePrefix = require('./getSnapshotFilenamePrefix'); module.exports = async (res, suffix) => { // Skip if no snapshots are being taken if (global.dceSeleniumConfig.noSnapshots) { return; } const filename = `${getSnapshotFilenamePrefix(suffix)}.json`; const json = ( typeof res === 'string' ? res : JSON.stringify(res) ); fs.writeFileSync(filename, json, 'utf-8'); };