This library provides two test suites:
- Unit tests: They are available in the
/test
folder and they test every single component. - End to end tests: They are available in the
/test-e2e
folder and they test the interaction with a real bluetooth device that you spawn on your own.
In order to run the available test suites you have to set up right DBus permissions.
Create the file /etc/dbus-1/system.d/node-ble-test.conf
with the following content (customize with userid)
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="%userid%">
<allow own="org.test"/>
<allow send_destination="org.test"/>
<allow send_interface="org.test.iface"/>
</policy>
</busconfig>
npm test
The end to end test will try to connect to a real bluetooth device and read some characteristics. To do that, you need two different devices. Prior to that, you need to create a test device via installation guide.
After you have prepared the device, you have to read via USB its mac address, then lunch the test suite.
TEST_DEVICE=00:00:00:00:00:00 npm run test:e2e