title: TS-Node with Mocha doesn't use TS_NODE_PROJECT
body: <p>I'm having trouble with using the env variable <code>TS_NODE_PROJECT</code> when ts-node is used for testing using Mocha.</p>
  
  <p>The project structure looks like this:</p>
  
  <pre><code>src/
    main_test.ts
    tsconfig.json
  package.json
  </code></pre>
  
  <p>In my test, I want to use an async function, which requires <code>"lib": ["es2018"]</code> as a compilation option.</p>
  
  <pre><code>// src/main_test.ts
  describe('', () =&gt; {
      it('test', () =&gt; {
          (async function() {})()
      });
  });
  
  // src/tsconfig.json
  {
    "compilerOptions": {
      "module": "commonjs",
      "target": "es5",
      "sourceMap": true,
      "lib": ["es2018"]
    },
    "exclude": [
      "../node_modules"
    ]
  }
  </code></pre>
  
  <p>To run the test, I use this command, but it results in an error:</p>
  
  <pre><code>TS_NODE_PROJECT='src' &amp;&amp; mocha --require ts-node/register src/*_test.ts
  # TSError: ⨯ Unable to compile TypeScript:
  # error TS2468: Cannot find global value 'Promise'.
  # src/main_test.ts(3,10): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
  </code></pre>
  
  <p>This means that <code>src/tsconfig.json</code> is not used. According to <a href="https://stackoverflow.com/questions/40635956/overriding-tsconfig-json-for-ts-node-in-mocha">Overriding `tsconfig.json` for ts-node in mocha
  </a> and the ts-node documentation, the command should pass the correct <code>tsconfig.json</code> path to ts-node.</p>
  
  <p>Moving <code>src/tsconfig.json</code> to project directory and running the same command causes the test to succeed. How can I pass the <code>tsconfig.json</code> path to ts-node so that the test compiles correctly?</p>