'use strict'; const { VirtualConsole } = require('jsdom'); const path = require('path'); const logger = require('../logger')(__filename); function getVirtualConsole(filepath) { const virtualConsole = new VirtualConsole(); const context = path.basename(filepath).replace(path.extname(filepath), ''); virtualConsole.on('error', (message) => logger.warn(`Error from JSDOM in ${context}: ${message}`)); virtualConsole.on('jsdomError', (message) => logger.warn(`Error from JSDOM in ${context}: ${message}`)); return virtualConsole; } module.exports = getVirtualConsole;