janpaul123 / paperprograms

Run Javascript on pieces of paper!
https://paperprograms.org
MIT License
498 stars 54 forks source link

Figure out an appropriate way to test this #3

Open chrisuehlinger opened 6 years ago

chrisuehlinger commented 6 years ago

In a project this complicated (i.e. one which relies on hardware, real-world lighting, browser features hidden behind flags, etc.) I imagine it's difficult to write useful unit tests in any conventional way. However, I also think it's really important that developers have a couple smoke tests to validate that they aren't breaking things when they check in code. I can think of a few steps that would help make the code more testable:

  1. Break the call to navigator.mediaDevices.getUserMedia() out of CameraVideo and instead pass a stream as a prop.
  2. In general, divorce the openCV-related stuff from the React components and just pass the components the minimal state they need to render. That state could be managed by something like Redux, although in my experience Redux itself is not always a good fit for apps whose state includes "blobby" things like MediaStreams.
  3. I haven't dug too deep into the server side, but if we could find a way to mock the DB (or just the calls to the DB) it would make it easier to test changes to the API.

Given that Paper Programs is still young, there might be other higher priorities right now. I just wanted to throw this out there as something to think about while moving forward or designing new parts of the system.

janpaul123 commented 6 years ago

Good ideas! Smoke tests would be nice indeed. But yeah some things are just way too experimental maybe? For example, I would imagine that a good calibration routine could eliminate all manual steps, in which case it would be a bit pointless to test those things.