UNPKG

dce-selenium

Version:

Selenium library to simplify testing and automatically snapshot the DOM.

22 lines (18 loc) 548 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)}.txt`; try { fs.writeFileSync(filename, res, 'utf-8'); } catch (err) { // Could not save text /* eslint-disable no-console */ console.log('\nCould not save text to file!'); console.log(err); process.exit(0); } };