# nRF Device Library Node.js Bindings

These are C++ bindings to the [nrf-device-lib](https://github.com/NordicPlayground/nrf-device-lib) written using the
[N-API](https://nodejs.org/dist/latest/docs/api/n-api.html).

## How to build

The following must be installed to build. See more detailed version information in YAML files for Azure.

-   [CMake](https://cmake.org/)
-   (Mac only) LLVM (see version information in YAML files for Azure). Can be installed using [brew](https://brew.sh/).
-   (Linux only) gcc, libusb.
-   (Max and Linux only) Ninja. Can be installed in Mac using [brew](https://brew.sh/).
-   (Windows only) Microsoft Visual Studio Community.
-   Node.js/npm. Can be installed in Mac/Linux using [nvm](https://github.com/nvm-sh/nvm) or in Windows using [nvm-windows](https://github.com/coreybutler/nvm-windows).

## Run tests

The tests expect certain devices to be connected in order to run. Having the following devices connected should be sufficient when runnint `npm test`

-   nRF52 Dongle (PCA10059) - Ensure it is in DFU mode
-   nRF52 (PCA10056) - Ensure there is no readback protection
-   nRF91 (PCA10090) - Ensure there is no readback protection


## Release

The [procedure to release `nrf-device-lib-js` is described in the internal wiki](https://projecttools.nordicsemi.no/confluence/display/WYLND/nrf-device-lib-js+release+procedure).

#### Notes (Q/A):
Q: I see no output of the console.log() in the CI
A: Possible solution would be to add spyOn(console, 'log').and.callThrough(); in beforeAll() -- from stackoverflow

Q: I want to add tab in the test logging
A: Add \t at the start of console.warn('\t', message);

Q: How can I conditionally skip a test?
A: You can use `xit` instead if `it` for running the test callback. See https://jasmine.github.io/api/4.6/global.html#xit for more info.
