NorthernMan54 / node-red-contrib-homebridge-automation

Homebridge and Node-RED Integration
Apache License 2.0
107 stars 18 forks source link

Initial automated testing #92

Closed dxdc closed 2 days ago

dxdc commented 3 years ago

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:

Once these are set you can even implement Travis rules for example that runs these tests on every PR.