ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

Why Puppeteer? #150

Closed mingos777 closed 5 years ago

mingos777 commented 5 years ago

Is there a reason to use Puppeteer specifically? It causes all sorts of problems for people not using the same browser or operating system. The tests/run.js file specifies the browser path to be /usr/bin/google-chrome but

Unfortunately, changing the path does not work and I get this:

mingos@Yodeling-Elk:~/dev/rot.js$ make test
node tests/run.js
(node:7325) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!

TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/home/mingos/dev/rot.js/node_modules/puppeteer-core/lib/Launcher.js:339:14)
    at Interface.helper.addEventListener (/home/mingos/dev/rot.js/node_modules/puppeteer-core/lib/Launcher.js:328:50)
    at Interface.emit (events.js:187:15)
    at Interface.close (readline.js:379:8)
    at Socket.onend (readline.js:157:10)
    at Socket.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1094:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:7325) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7325) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
^CMakefile:39: recipe for target 'test' failed
make: *** [test] Interrupt

Is there a reason for using Puppeteer instead of just plain Mocha or Jasmine?

ondras commented 5 years ago

Hi @mingos777,

I agree that using puppeteer-driven Chrome is sub-optimal. Unfortunately, rot.js uses a non-trivial amount of clientside-specific APIs (canvas, CSS OM), so testing tools that are native to nodejs cannot be really used. In other words, we need a real web browser to run all rot.js tests.

You can do that manually by opening https://github.com/ondras/rot.js/blob/master/tests/index.html in your browser: this uses the client-side Jasmine test runner. I am open to suggestions how to do this in an automated way from the command line

My experience with puppeteer is pretty low, so I cannot explain why your local chromium-based setup fails. But it seems to me that the issue is with the puppeteer-chromium binding, not related to rot.js testing infrastructure.

mingos777 commented 5 years ago

OK, I was unaware of browser-specific APIs usage. Closing the issue for now as it was more of a question than a request to provide a fix.