using flowtype to statically check mocha test code : <p>I have some complex Mocha code which I would like to statically check with FlowType because why not?</p>

<p>Below is a minimal repro:</p>

<pre><code>/* @flow */

describe('it', function () {
    it('fails', function() {
        const s: number = 'flow spots this error';
    });
});
</code></pre>

<p>When I run Flow on this, Flow does indeed spot the problem with the assignment of <code>string</code> to <code>number</code> which shows that the approach is working to some extend.</p>

<p>However, I also get:</p>

<pre><code>test/test.js:4
  4: describe('it', function () {
     ^^^^^^^^ identifier `describe`. Could not resolve name

test/test.js:5
  5:     it('fails', function() {
         ^^ identifier `it`. Could not resolve name
</code></pre>

<p>&hellip; apparently the Mocha test definitions run in an environment where these functions are globally available but looking at the test file there's nothing that would allow Flow to detect that.</p>

<p>I am not sure these problems are specific to Mocha but I don't feel I can confidently frame the question in broader terms, so my questions are:</p>

<ol>
<li>how can I have Flow type check Mocha test code without suppressing every line that contains <code>describe</code> or <code>it</code> ?</li>
<li>is this is an instance of a broader class of situations and, if so, what would the latter be?</li>
</ol>
