title: Test specific file using Jest
body: <p>In my project folder I have lots of subfolders with js code and test.js file in each of them. I want to be able to test specific file. For example, let's say in our project folder we have 'fib' folder:</p>
  <pre><code>C:.
  └───exercises
      └───fib
              fib-test.js
              index.js
  </code></pre>
  <p>Now, from the exercises folder I execute jest command:</p>
  <pre><code>jest fib\fib-test.js
  </code></pre>
  <p>And I get:</p>
  <pre><code>No tests found, exiting with code 1
  Run with `--passWithNoTests` to exit with code 0
  In C:\exercises
    62 files checked.
    testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 26 matches
    testPathIgnorePatterns: \\node_modules\\ - 62 matches
    testRegex:  - 0 matches
  Pattern: fib\fib-test.js - 0 matches
  </code></pre>
  <p>If I do just jest, I'll get all tests ran. If I move fib folder out of the exercises folder it works as expected. Here is the code for all of the files:</p>
  <p><strong>index.js:</strong></p>
  <pre><code>function fib(n) {}
  
  module.exports = fib;
  </code></pre>
  <p><strong>test.js:</strong></p>
  <pre><code>const fib = require('./index');
  
  test('Fib function is defined', () =&gt; {
    expect(typeof fib).toEqual('function');
  });
  
  test('calculates correct fib value for 1', () =&gt; {
    expect(fib(1)).toEqual(1);
  });
  
  test('calculates correct fib value for 2', () =&gt; {
    expect(fib(2)).toEqual(1);
  });
  
  test('calculates correct fib value for 3', () =&gt; {
    expect(fib(3)).toEqual(2);
  });
  
  test('calculates correct fib value for 4', () =&gt; {
    expect(fib(4)).toEqual(3);
  });
  
  test('calculates correct fib value for 15', () =&gt; {
    expect(fib(39)).toEqual(63245986);
  });
  </code></pre>
  <p><strong>package.json</strong>:</p>
  <pre><code>{
    &quot;name&quot;: &quot;dev&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;jest&quot;: {
      &quot;testEnvironment&quot;: &quot;node&quot;
    },
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;
  }
  </code></pre>
  <p>I've tried all of these solutions with no success:</p>
  <ol>
  <li><a href="https://stackoverflow.com/questions/57045201/run-single-test-of-a-specific-test-suite-in-jest">Run single test of a specific test suite in Jest</a></li>
  <li><a href="https://stackoverflow.com/questions/42827054/how-do-i-run-a-single-test-using-jest/42897994">How do I run a single test using Jest?</a></li>
  <li><a href="https://stackoverflow.com/questions/28725955/how-do-i-test-a-single-file-using-jest">How do I test a single file using Jest?</a></li>
  </ol>
  <p>But was able to achieve the desired result running jest command with --watch flag and then in regex menu entering the relative path to the fib\test.js. The question is how to do it without entering watch menu?</p>