Thursday, 29 November 2018

Exclude file from compilation during karma test runs

I am using angular-cli with Karma, and I need to exclude a particular file from being compiled when running unit tests.

The file in question is referenced in the error below, where it cannot be compiled due to a module not being present it relies on.

enter image description here

This file is used by other projects where the module will be present and so compiles fine, its just in this particular project it does not need compilation but still needs to be exported.

I have been trying to use the excludes option in the compiler options but I have not been able to get it to be ignored.

My angular-cli.json file has an entry like so:

"testTsconfig": "tsconfig.spec.json"

And in the tsconfig.spec.json I have added an excludes property specifying the path of the file to exclude:

"exclude": [
        "**/o3-test-harness.class.ts"
    ]

But it's not making any difference.

Should this be possible? Thanks



from Exclude file from compilation during karma test runs

No comments:

Post a Comment