Closed TrevorFSmith closed 6 years ago
Fixing the conflicts, now...
nice work! could you file an issue for Travis CI integration?
@TrevorFSmith why have you added chai.js
inside test instead of adding it as a dev dependency on package.json
?
Also you're including mocha
on the package.json
but use the cdn on index.html
: https://github.com/mozilla/xr-input/pull/5/files#diff-15ba74c135752e5b9ea36b87677e8603R11
Ok, @fernandojsg I've set it up so that the browser based testing uses all local files instead of the CDN and removed mocha from the package.json since we're not (yet) using it for command line testing.
One thing is that the browser tests don't work if we open it via a file:// url and only work if we open the index.html via a web server. Perhaps I should add a npm run script that starts a web server and echos to stdout that the user should open http://127.0.0.1:8000/test/ ?
Looking again into it I don't like the idea of needing to run your own server and load a website for it, and it also won't work on CI. You would expect to have a npm run test
command to run things locally even if they need a browser (using karma for example).
You could take a look at aframe for example, there we have mocha, chai and karma and we can run the test on a browser (ffox and chrome) and on node, I believe a good starting point could be to try to replicate that config.
Ok, I'm going to close this PR and set up mocha+chai on the CLI on a branch in my fork.
Before we start actually implementing anything, I wanted to suggest that we use Potassium's bare-bones, in-browser testing framework since most of the functionality will need the browser APIs and our needs are pretty simple.
But, if someone has strong opinions about testing, I'm open to other frameworks, especially if they make it easy to run tests in a headless browser from the command line and using CI.
I added a simple event and listener system, also pulled in from Potassium, that I think we can use to avoid causing GC. The tacitc I took with the KeyboarInputSource was to create a single instance of InputEvent for each event type and then pass context using parameters. I think that this will keep events and context data on the stack, but it's a weird pattern so I'm looking for feedback on that, too.