Mock recorder and playback tool for react-native-ble-plx. Enables fast and robust integration tests for your Bluetooth/BLE app.
This tool will help developers of React Native apps that talk to Bluetooth/BLE devices. Avoid having a lot of slow and fragile end-to-end tests taking more than an hour to run on physical devices and a physical CI server!
If you can run your UI tests with pre-recorded BLE traffic, you get very fast and robust tests, that are actual integration tests, since you are not writing your mocks by hand.
You will create a separate mock recorder app, using the "react-native-ble-plx-mock-recorder-mocha-template" template for React Native to occasionally record actual traffic needed by your tests.
Then use this library to play back the BLE traffic every time you run your Jest UI tests, and enjoy the speed of up to 100 of tests per second.
For more information, check out the blog post.
- A Bluetooth/BLE device, powered on, nearby, not connected to a phone.
- A React Native app talking to the BLE device.
- An Android phone, plugged into your computer.
- (Support for iPhone is planned).
- A React Native development environment: https://reactnative.dev/docs/environment-setup.
- bash on your path.
- If on Windows, consider using Git Bash (https://gitforwindows.org/).
npm install
npm run demo:app
# then close the app and the Metro popup terminal window
npm run demo:recorder
# from here on you can unplug phone and power down BLE device
npm run demo:app:test
To get started, read how to build your own demo from scratch. Then apply the same steps to the app you would like to test.
TODO
See ARCHITECTURE.md
Currently a large part of the central API of react-native-ble-plx
is implemented, but several methods which have not been needed yet, are missing. They should be easy to add. Feel free to submit a Pull Request!
Contributions are welcome! Please open an issue with your suggestions and/or submit a PR. PRs should pass npm test
and not decrease code coverage.
@larsthorup |
@muscapades |
# git commit && git push
# wait for CI to pass
# clean workspace
git checkout main
git pull
npm run test:e2e
npm run bump
npm run publish
# git commit && git push
Then manually verify local react-native-ble-plx-mock-recorder-mocha-template and publish that.