<p dir="auto">In some cases, you'd like to set up your testing module the same as a larger module you're exporting, but want to mock out some declarations. Currently there is no way to <em>remove</em> a declaration though, so you'd have to make a whole new module and duplicate your list.</p>
<p dir="auto">e.g., now</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// in lib
@NgModule({
  declarations: [A, B, C, D, E]
})
class MyLibModule {};

// in test for E, we want to mock out D
TestBed.configureTestingModule({
  declarations: [A, B, C, MockD, E]
});"><pre class="notranslate"><span class="pl-c">// in lib</span>
@<span class="pl-smi">NgModule</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">declarations</span>: <span class="pl-kos">[</span><span class="pl-smi">A</span><span class="pl-kos">,</span> <span class="pl-smi">B</span><span class="pl-kos">,</span> <span class="pl-smi">C</span><span class="pl-kos">,</span> <span class="pl-smi">D</span><span class="pl-kos">,</span> <span class="pl-smi">E</span><span class="pl-kos">]</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span>
<span class="pl-k">class</span> <span class="pl-smi">MyLibModule</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-c">// in test for E, we want to mock out D</span>
<span class="pl-smi">TestBed</span><span class="pl-kos">.</span><span class="pl-en">configureTestingModule</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">declarations</span>: <span class="pl-kos">[</span><span class="pl-smi">A</span><span class="pl-kos">,</span> <span class="pl-smi">B</span><span class="pl-kos">,</span> <span class="pl-smi">C</span><span class="pl-kos">,</span> <span class="pl-smi">MockD</span><span class="pl-kos">,</span> <span class="pl-smi">E</span><span class="pl-kos">]</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Instead it would be nice to be able to do something like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// in test for E
TestBed.configureTestingModule({
  imports: [MyLibModule],
  remove: [D],
  declarations: [MockD]
});"><pre class="notranslate"><code class="notranslate">// in test for E
TestBed.configureTestingModule({
  imports: [MyLibModule],
  remove: [D],
  declarations: [MockD]
});
</code></pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="WARNING in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
87:15-102 Critical dependency: the request of a dependency is an expression
    at ImportContextDependency.getWarnings (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/webpack/lib/dependencies/ImportContextDependency.js:28:4)
    at Compilation.reportDependencyErrorsAndWarnings (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/webpack/lib/Compilation.js:663:24)
    at Compilation.finish (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/webpack/lib/Compilation.js:526:9)
    at /home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/webpack/lib/Compiler.js:472:16
    at /home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/tapable/lib/Tapable.js:225:11
    at /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/html-webpack-plugin/index.js:60:9
    at tryCatcher (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/promise.js:691:18)
    at Async._drainQueue (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:666:20)
    at tryOnImmediate (timers.js:639:5)
    at processImmediate [as _immediateCallback] (timers.js:611:5)
"><pre class="notranslate">WARNING <span class="pl-k">in</span> ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
87:15-102 Critical dependency: the request of a dependency is an expression
    at ImportContextDependency.getWarnings (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/webpack/lib/dependencies/ImportContextDependency.js:28:4)
    at Compilation.reportDependencyErrorsAndWarnings (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/webpack/lib/Compilation.js:663:24)
    at Compilation.finish (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/webpack/lib/Compilation.js:526:9)
    at /home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/webpack/lib/Compiler.js:472:16
    at /home/patrikx3/Projects/patrikx3/corifeus/corifeus-web-api/node_modules/tapable/lib/Tapable.js:225:11
    at /home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/html-webpack-plugin/index.js:60:9
    at tryCatcher (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/promise.js:691:18)
    at Async._drainQueue (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-builder/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:666:20)
    at tryOnImmediate (timers.js:639:5)
    at processImmediate [as _immediateCallback] (timers.js:611:5)
</pre></div>