mozilla / action-input

INACTIVE - http://mzl.la/ghe-archive - A framework-agnostic input library that progressively handles flat, portal, and immersive web apps.
Mozilla Public License 2.0
9 stars 3 forks source link

Testing framework #5

Closed TrevorFSmith closed 6 years ago

TrevorFSmith commented 6 years ago

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.

TrevorFSmith commented 6 years ago

Fixing the conflicts, now...

cvan commented 6 years ago

nice work! could you file an issue for Travis CI integration?

fernandojsg commented 6 years ago

@TrevorFSmith why have you added chai.js inside test instead of adding it as a dev dependency on package.json?

fernandojsg commented 6 years ago

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

TrevorFSmith commented 6 years ago

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.

TrevorFSmith commented 6 years ago

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/ ?

fernandojsg commented 6 years ago

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).

fernandojsg commented 6 years ago

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.

TrevorFSmith commented 6 years ago

Ok, I'm going to close this PR and set up mocha+chai on the CLI on a branch in my fork.