manekinekko / angular-web-bluetooth

The missing Web Bluetooth module for Angular
https://manekinekko.github.io/angular-web-bluetooth/
MIT License
196 stars 58 forks source link

Jest testing instead of Karma & Jasmine + Examples & helpers #74

Closed fayway closed 3 years ago

fayway commented 3 years ago

Hello @manekinekko,

This is the best Jest setup I could come up with for running tests from a terminal and from my IDE (Intellij), feel free to review it and suggest improvements.

To run all tests:

ng test

(or npm test)

To only run angular-web-bluetooth lib tests:

ng test @manekinekko/angular-web-bluetooth 

(or npm run test:lib)

To only run angular-web-bluetooth-starter tests:

ng test angular-web-bluetooth-starter 

(or npm run test:starter)

I've also added some examples of automated tests with helper classes to exercise services and components. We can use them as a TDD support to add new features without the need to launch the whole app and to have a real BLE peripheral or a mobile simulator app, it can boost our productivity and also help newbies to understand the Bluetooth Web API with a simple and a naive implementation.

I hesitated to use RxJs marble testing, what's you opinion on this topic? Can this approach may be overkill?

Any feedback is welcome :)