title: Jest config not picked in git submodule npm package from root
body: <p>For an RN app.
  I have a project structure like</p>
  <pre><code>root git repo
  |-jest.config
  |-package.json
  |-screens/
  |--git submodule
  |--git submodule
  |--.lintstagedrc
  </code></pre>
  <p>one repo at root with package.json and jest.config
  and multiple git submodules in screens folder</p>
  <p>Each submodule is a npm package which is symlinked in node modules and added in package.json pointing to the git branch.</p>
  <p>Now what i wanted to do was add a precommit hook in each submodule and use the root configurations for jest to run when anything is committed in the submodule.</p>
  <p>I am using husky and have defined a .lintstagedrc file in the screens folder which would be picked while running husky.</p>
  <pre><code>{
    &quot;./**/app/**/*.{js,jsx,ts,tsx}&quot;: [
      &quot;eslint --fix --ext .js,.jsx,.ts,.tsx --plugin tsc --rule 'tsc/config: [2, {configFile: \&quot;../../../tsconfig.json\&quot;}]'&quot;,
      &quot;jest  --config ../../../jest.config.js --bail --forceExit --passWithNoTests --findRelatedTests&quot;
    ]
  }
  </code></pre>
  <p>i am trying to set the jest config using the args however when the commit hook runs it does not pick the config and gives a type error for RN polyfill files</p>
  <pre><code>Syntax Error node_modules/@react-native/polyfills/error-guard.js: Missing semicolon. (14:4)
   &gt; 14 | type ErrorHandler = (error: mixed, isFatal: boolean) =&gt; void;
  </code></pre>
  <p>The same runs correctly if the files are not part of submodule and directly in the root repo(while being at the same path)</p>
  <p>when running <code>npx jest --showConfig</code> it is correctly showing the required jest config. but running jest always fails.</p>
  <p>How do i get jest to pick the current config and assume the root folder for config is the root repo and not the submodule npm package as i suggest having a package.json defined in submodule might be causing issues</p>
  <p>Or that given the submodule is symlinked to node_modules folder at root might be the issue.</p>
  <p>Jest config(payments is an example submodule)</p>
  <pre><code>module.exports = {
    // The preset is a node environment that mimics the environment of a React Native  app. Because it doesn't load any DOM or browser APIs, it greatly improves Jest's startup time.
    verbose: true,
    preset: 'react-native',
    // It helps you greatly improve the test speed.It does so by creating a cache of compiled modules so that it doesn't have to compile the node_modules every time we run tests.
    cacheDirectory: './cache',
    // Defines the files which we want to skip while generating coverage reports.
    // coveragePathIgnorePatterns: ['./src'],
    // Defines the threshold limit for all the tests to pass.If the coverage is less than the defined limit, the tests would fail.This helped us in keeping code coverage high throughout development.
    coverageThreshold: {
      global: {
        // global thresholds
        branches: 23,
        functions: 25,
        lines: 32,
        statements: 32,
      },
    },
  
    globals: {
      'ts-jest': {
        diagnostics: false,
      },
    },
  
    collectCoverageFrom: [
      './src/**/*.js',
      './src/**/*.ts',
      './src/**/*.tsx',
      '!**/node_modules/**',
      '!**/vendor/**',
    ],
  
    testPathIgnorePatterns: ['src/.+((?:.ignored)|(?:mock)).(ts|js)x?'],
  
    transform: {
      '^.+\\.(ts|tsx|js|jsx)$': 'babel-jest',
    },
  
    // All the npm modules which need to be transpiled are added here.These modules are basically ES6/ 7 modules.
    transformIgnorePatterns: [
      '/node_modules/(?!(jest-)?@?react-native|payments|react-clone-referenced-element|react-navigation|@react-native-community|rn-range-slider|victory|react-native-svg|recoil)',
    ],
    setupFilesAfterEnv: [
      '&lt;rootDir&gt;/src/tests/setupTests.js',
      '&lt;rootDir&gt;/node_modules/react-native-gesture-handler/jestSetup.js',
      '@testing-library/jest-native/extend-expect',
    ],
    moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  
    moduleNameMapper: {
      '\\.svg': '&lt;rootDir&gt;/src/tests/mocks/svgMock.js',
      '^src/(.*)': '&lt;rootDir&gt;/src/$1',
      '^config/(.*)': '&lt;rootDir&gt;/config/$1',
      '^app/(.*)': '&lt;rootDir&gt;/app/$1',
      '^setup/(.*)': '&lt;rootDir&gt;/setup/$1',
      '^payments/(.*)': '&lt;rootDir&gt;/src/screens/payments/$1',
    },
  
    notify: true,
    notifyMode: 'always',
  };
  </code></pre>