2020-11-23 03:32:56 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { VirtualConsole } = require('jsdom');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
const logger = require('../logger')(__filename);
|
|
|
|
|
|
|
|
function getVirtualConsole(filepath) {
|
|
|
|
const virtualConsole = new VirtualConsole();
|
2020-11-24 03:29:44 +00:00
|
|
|
const context = path.basename(filepath).replace(path.extname(filepath), '');
|
2020-11-23 03:32:56 +00:00
|
|
|
|
2021-11-20 22:59:15 +00:00
|
|
|
virtualConsole.on('error', (message) => logger.warn(`Error from JSDOM in ${context}: ${message}`));
|
|
|
|
virtualConsole.on('jsdomError', (message) => logger.warn(`Error from JSDOM in ${context}: ${message}`));
|
2020-11-23 03:32:56 +00:00
|
|
|
|
|
|
|
return virtualConsole;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = getVirtualConsole;
|