Including some code that I've used successfully on one of my NR modules that allows for automated testing. It's very basic right now, but you can see some more examples of the kinds of tests I ran here:
You can access this via (after, npm run install):
npm run test
Doing this on your plugin may be a bit more complicated because it loads HAP-Node-Client and we may need to mock that somehow to return sample JSON instead of what is truly returned by HB.
Anyway, figured this could be a start toward automated testing, and avoiding future issues.
You can also try:
npm run format to run the formatter
npm run lint to check for JS errors
npm run coverage to run test coverage
Once these are set you can even implement Travis rules for example that runs these tests on every PR.
Including some code that I've used successfully on one of my NR modules that allows for automated testing. It's very basic right now, but you can see some more examples of the kinds of tests I ran here:
You can access this via (after,
npm run install
):npm run test
Doing this on your plugin may be a bit more complicated because it loads HAP-Node-Client and we may need to mock that somehow to return sample JSON instead of what is truly returned by HB.
Anyway, figured this could be a start toward automated testing, and avoiding future issues.
You can also try:
npm run format
to run the formatternpm run lint
to check for JS errorsnpm run coverage
to run test coverageOnce these are set you can even implement Travis rules for example that runs these tests on every PR.