only import node-html-parser when running the unit tests

This commit is contained in:
Bruno Windels 2021-12-01 17:26:00 +01:00
parent 1a618dd106
commit bb9362ee8b

View File

@ -352,10 +352,13 @@ export function parseHTMLBody(platform, mediaRepository, allowReplies, html) {
return new MessageBody(html, parts);
}
import nodeHtmlParser from "node-html-parser";
const {parse} = nodeHtmlParser;
export function tests() {
export async function tests() {
// don't import node-html-parser until it's safe to assume we're actually in a unit test,
// as this is a devDependency
const nodeHtmlParser = await import("node-html-parser");
const {parse} = nodeHtmlParser.default;
class HTMLParseResult {
constructor(bodyNode) {
this._bodyNode = bodyNode;