1.1.0 • Published 7 years ago
@milanzor/homey-mock v1.1.0
Homey Mock
Mock Homey for unit-testing purposes
What
This package provides a mocking class to allow developers to unit-test their Athom Homey apps
Installation and usage
My preferred (the only one I have used actually...) JS unit testing utilities are Mocha together with Chai, so here's how you use them to mock Homey and unit test your app:
- Install the following DEV dependencies in your app project:
npm install -D mocha chai mock-require homey-mock - Edit your package.json's
scripts => testentry tomocha ./test/**/*.test.js, this will allow you to runnpm testlater and all your test files will be executed. - Create a
testdirectory in the root of your project - Create a file in the
testdirectory called, say,myapp.test.js - Have a look at the
./examples/basic.test.jsand./examples/homeyapp.test.jsfor some example code to put in your .test.js file. - Run
npm testand see the result of your unit tests!
Working example
For a working example, have a look at our Countdown app: https://github.com/NotQuiteZen/homey.countdown and it's travis integration for automated Unit Tests: https://travis-ci.com/NotQuiteZen/homey.countdown
IMPORTANT NOTE
- This currently only mocks a few functions that Homey supports, if you are missing anything, stuff will be added as I need them, but feel free te leave an issue or even a pull request.
- Hit me up on Athom's Slack community on
@milanzor