Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Running tests within Nx Workspace projects


    In this lesson we look at how we can run tests inside of an Nx Workspace project, allowing you to test a specific library, or the whole project.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: Here we have an Nx workspace. We have one library which contains a counter module and counter component as well as inside of our apps, we have an app component with an app component spec.

    Therefore, we have tests inside of the app directory and tests inside of the live directory. To run the unit tests inside of our application, we can run ng test. This will run the app component .spec.ts test, and it will also run all of the library tests.

    If we just wanted to run the unit tests for a particular library, we can use ng test--project = counter. This will no longer run the app tests. It will simply run the counter library tests.