title: How to override an imported module in nestjs testing?
body: <p>I'm quite new on <code>nestjs</code>, met an issue regarding how to override the <code>load</code> function of <code>ConfigModule</code>, hope someone can help me out, thanks in advance!</p>
  <p>My e2e testing:</p>
  <pre class="lang-js prettyprint-override"><code>const moduleForTesting = await Test.createTestingModule({imports: [AppModule]});
  </code></pre>
  <p>My App Module:</p>
  <pre class="lang-js prettyprint-override"><code>import config from './config/index'
  
  @Module({
    imports: [ConfigModule.forRoot({isGlobal: true, load: [config]})]
  })
  </code></pre>
  <p>My <code>config/index</code> file:</p>
  <pre class="lang-js prettyprint-override"><code>export default async () =&gt; {
    someConfigs: ...
  }
  </code></pre>
  <p>Now I want the e2e testings use another configurations, but I don't know how to override the AppModule, nor the <code>load</code> function:</p>
  <pre class="lang-js prettyprint-override"><code>// AppModule
  import config from './config/index' // This is ok for production, but need to be overridden in testing
  
  ...
    imports: [ConfigModule.forRoot({isGlobal: true, load: [config]})]
  </code></pre>