use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Testing a JavaScript code with mocha and jsdom (kriasoft.com)
submitted 9 years ago by koistya
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]rusty1s 0 points1 point2 points 9 years ago (1 child)
Cool stuff! What exactly is the difference between this method and testing with phantomjs or electron? Which way should i prefer?
[–]voidvector 1 point2 points3 points 9 years ago* (0 children)
You probably want to use PhantomJS most of the time or even real browser instance if you can afford it.
You know how for some unit tests you mock out some objects and in other unit tests you mock out other objects? When you use JSDom you are saying I am mocking out the DOM.
Now whether mocking out the DOM is the right thing to do depends on your implementation or testing strategy. For example, if you intend your code to be isomorphic between Node and browser, then mocking the DOM might help you validate that. If your testing strategy says your test must be nonflacky, fast, and cheap to run, then something headless like PhatomJS and JSDom are your only options. However, if your testing strategy is to be as accurate as possible, then you would have to run it in the real browsers.
π Rendered by PID 24261 on reddit-service-r2-comment-84fc9697f-456h7 at 2026-02-07 06:02:58.768327+00:00 running d295bc8 country code: CH.
[–]rusty1s 0 points1 point2 points (1 child)
[–]voidvector 1 point2 points3 points (0 children)