Demos: Make casper tests check for JS errors and fail if any are found

(cherry picked from commit cb9112abb3acf73abc104051ac318647055b189c)