Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tries to find Jest config in package dependencies #67

Open
tf opened this issue Apr 13, 2021 · 1 comment
Open

Tries to find Jest config in package dependencies #67

tf opened this issue Apr 13, 2021 · 1 comment

Comments

@tf
Copy link

tf commented Apr 13, 2021

I'm maintaining a package that contains import statements in its Rollup outputs which are transpiled via Webpack in applications using the package. In the Jest tests of another package, I am importing things from this package:

// package-b/some-test.s
import {something} from 'package-a';

This works soon as I configure Jest to also Babel transpile package-a as proposes in this Jest issue

When running eslint I'm seeing the following error, though:

Error: jestConfigFile not found in /path/to/package-b/node_modules/package-a/jest.config.js

It looks like the Jest resolver is also applied to imports found in node module dependencies. Scoping the importer to tests as suggested in the README additions of #38 also does not change anything since the linted file determines resolvers - not the file currently parsed for import statements. #32 addresses the same issue, but makes it fail silently even if the Jest config in the root project cannot be found.

The workaround that I found is to reference the Jest config with an absolute path in eslintrc.js:

 "settings": {
    "import/resolver": {
      "jest": {
        "jestConfigFile": path.resolve(__dirname, "./jest.config.js")
      }
    }
  }

I would have expected a relative jestConfigFile path to always be resolved relative to the .eslintrc.js file, not the package root of the file currently parsed for imports.

I'm mainly leaving this here as future reference for others.

@andrewtsun25
Copy link

+1, still experiencing this issue today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants