javascriptnode.jstypescriptnestjsnomachine-nx

How to test all the projects or libraries in NestJS (nx)?


We have setup a NestJS project with multiple libraries in it using Nx. We are able to run tests of projects/libraries independently like,

npx nx test lib1 --coverage

This works fine, but we have several libraries and modules, we want to run test across all and consolidate the coverage. How can we achieve that ?


Solution

  • As stated in nx documentation, you can run the following command to run all tests

     nx run-many --target=test
    

    The attached link is to their documentation regarding this

    https://nx.dev/nx/run-many#examples