title: Exclude file from compilation during karma test runs
body: <p>I am using angular-cli with Karma, and I need to exclude a particular file from being compiled when running unit tests.</p>
  
  <p>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.</p>
  
  <p><a href="https://i.stack.imgur.com/oEzyw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oEzyw.png" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <p>My directory structure is as follows:</p>
  
  <pre><code>index.ts
      - /src
      - /testing
  </code></pre>
  
  <p>In my index.ts file I have a single export:</p>
  
  <pre><code>export * from './src/core';
  </code></pre>
  
  <p>TS source files under my <code>testing</code> folder are getting picked up by the compiler, and I am unsure why as I am not importing any files under this folder in files under my <code>src</code> folder or anywhere else from what I can tell.</p>
  
  <p>I want to prevent the compiler from picking up my testing folder altogether, but I cannot get it to ignore it.</p>
  
  <p>I am using angular-cli, and in my .angular-cli.json file I have these lines:</p>
  
  <pre><code>"tsconfig": "tsconfig.json",
  "testTsconfig": "tsconfig.spec.json"
  </code></pre>
  
  <p>Both of these files are located under my <code>src</code> folder, I tried adding some exclude patterns to my tsconfig.spec.json like so:</p>
  
  <pre><code>"exclude": [
          "../testing",
          "testing"
      ]
  </code></pre>
  
  <p>But this made no difference.</p>
  
  <p>I then wondered if karma was definitely using my tsconfig.spec.json file and so I added the following:</p>
  
  <pre><code> karmaTypescriptConfig : {
          tsconfig: '.src/tsconfig.spec.json',
      }
  </code></pre>
  
  <p>But again, still no difference is made, my testing folder gets picked up by the compiler when preparing to run my tests.</p>
  
  <p>I am unsure what else to try, I have updated my versions of TypeScript(3.1.6) and Karma(3.1.1) to the latest.</p>
  
  <p>Has anyone got any ideas on what may be going on here? </p>
  
  <p>Thanks</p>