Monday, 8 April 2019

How can I add node_modules folder to Istanbul test coverage report?

Within my org we have a few npm-like teams. My team creates a library of angular components, but we have had to develop inside of node_modules to keep our paths consistent when other teams pull in our code base.

To do so, I have had to update the tsconfig.app.json. And for our unit tests, I have had to update a few files:

test.ts

const nodeContext = require.context('../node_modules/uicomponents', true, /\.spec\.ts/);
// const  context = require.context('./', true, /\.spec\.ts/);

// context.keys().map(context);
nodeContext.keys().map(nodeContext);

tsconfig.spec.json

"include": [
  "**/*.d.ts",
  "../node_modules/uicomponents/**/*.ts"
]

With this, our unit tests run perfectly, but our Istanbul/karma code coverage isn't reporting for test files in node_modules.

How can I tell Istanbul to include node_modules/uicomponents, and ideally, exclude src/app?

I have attempted to makes similar changes as suggested HERE, but I'm still not getting a report for my node_modules test files.



from How can I add node_modules folder to Istanbul test coverage report?

No comments:

Post a Comment