title: How can I import the Chai 'expect()' function globally in TypeScript?
body: <p>Other related questions are just asked about JavaScript, but I know the <a href="https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#JavaScript" rel="nofollow noreferrer">Chai</a> team already provided 'chai/register-expect', etc..</p>
  <p>I was migrating from <a href="https://en.wikipedia.org/wiki/Jest_(JavaScript_framework)" rel="nofollow noreferrer">Jest</a> to Chai, and when I used Jest it was done just by typing 'jest' to the &quot;types&quot; field in file <em>tscofnig.json</em>. Then the <em>expect</em> function was automatically referred to with <code>@types/jest index.d.ts</code>.</p>
  <p>But <em>@types/chai</em> or Chai do not support this. And they recommend, before reporting an issue, to post on Stack Overflow. What on Earth, right?</p>
  <p>After surfing about this, I realize everyone imports the 'expect' function per file, like <a href="https://github.com/typeorm/typeorm" rel="nofollow noreferrer">TypeORM</a> or other TypeScript projects... Holy bleep, it is so awwwwwwwful.</p>
  <p>Why on Earth should I import <em>expect()</em> per file? Isn't there a way to avoid that?</p>
  <p>I can return to Jest, but that performance is so horrible fecal matter. It is better importing <em>expects</em> for all files.</p>
  <p><code>mocha -r chai/register-expect</code> is not working either.</p>
  <p>I was testing:</p>
  <pre><code>npx mocha -r node_modules/ts-node/register/transpile-only -r chai/register-expect -r ts-node/register -r tsconfig-paths/register some.test.ts
  </code></pre>
  <p>Here is my <em>tsconfig.json</em> file.</p>
  <pre><code>{
      &quot;compilerOptions&quot;: {
          &quot;module&quot;: &quot;commonjs&quot;,
          &quot;esModuleInterop&quot;: true,
          &quot;target&quot;: &quot;es5&quot;,
          &quot;noImplicitAny&quot;: false,
          &quot;moduleResolution&quot;: &quot;node&quot;,
          &quot;sourceMap&quot;: true,
          &quot;outDir&quot;: &quot;dist&quot;,
          &quot;baseUrl&quot;: &quot;src&quot;,
          &quot;skipLibCheck&quot;: true,
          &quot;downlevelIteration&quot; : true,
          &quot;paths&quot;: {
               ... bla bla
              &quot;main/*&quot; : [
                  &quot;main/*&quot;
              ],
              &quot;controllers/*&quot; : [
                  &quot;main/controllers/*&quot;
              ],
              &quot;middleware/*&quot; : [
                  &quot;main/middleware/*&quot;
              ],
              &quot;*&quot;: [
                  &quot;node_modules/*&quot;
              ]
          },
          &quot;types&quot; : [
              &quot;node&quot;,
              &quot;mocha&quot;,
              &quot;chai&quot;
          ],
          &quot;typeRoots&quot;: [
              &quot;node_modules/@types&quot;,
              &quot;types&quot;
          ],
          &quot;lib&quot;: [
              &quot;es2017&quot;,
              &quot;dom&quot;
          ],
          &quot;emitDecoratorMetadata&quot;: true,
          &quot;experimentalDecorators&quot;: true,
          &quot;resolveJsonModule&quot; : true
      },
      &quot;exclude&quot;: [
          &quot;node_modules&quot;
      ],
      &quot;include&quot;: [
          &quot;src/**/*.ts&quot;,
          &quot;**/*.test.ts&quot;
      ]
  }
  </code></pre>