Skip to content

Commit a2d6666

Browse files
committed
Throw in a human readable way if jsdom is not installed locally when running outside of a browser
1 parent 31c1016 commit a2d6666

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,11 @@ module.exports = {
433433
htmlDocument.write(subject);
434434
htmlDocument.close();
435435
} else {
436-
htmlDocument = require('jsdom').jsdom(subject);
436+
try {
437+
htmlDocument = require('jsdom').jsdom(subject);
438+
} catch (err) {
439+
throw new Error('The assertion `when parsed as html` was run outside a browser, but could not find the `jsdom` module. Please npm install jsdom to make this work.');
440+
}
437441
}
438442
return this.shift(expect, htmlDocument, 0);
439443
});

0 commit comments

Comments
 (0)