Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular library secondary entrypoint test code coverage problem

I am using angular library with secondary entrypoint My library folder structure is

  • my-library
    • secondary-entrpoint 1
      • service 1
    • secondary-entrypoint 2
      • service 2
    • src

And I used this command ng test my-library --code-coverage

The secondary entry points' service test doesn't execute.

Then I tried, changing "test.ts" context path('./') with '../' which is under the src folder. Tests were executed but code coverage doesn't create.

How can I execute tests for a secondary entry point?

like image 275
Mert yılmaz Avatar asked Sep 08 '26 20:09

Mert yılmaz


1 Answers

That is because the source root of your project is pointing to projects/your-library/src and when running tests it does not take into account the other entry points.

To fix this just change the sourceRoot property in your "angular.json" file to projects/your-library, everything else should still work fine.

like image 151
Andres Ballester Avatar answered Sep 12 '26 12:09

Andres Ballester