Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Conversation

@gigaSproule
Copy link

We were noticing that with gatsby-source-contentful, it was unable to find the package.json (not sure why), but there was nothing being printed out. If the error is ignored, jest is able to handle it perfectly fine.

@grpawel
Copy link

grpawel commented Apr 6, 2022

I have the same issue and came up with the same fix. The problem is it would be a regression for #10

In my case the error was caused by require('jsonfile') in https://unpkg.com/[email protected]/lib/json/jsonfile.js not finding the dependency in /projectPath/node_modules/fs-extra/node_modules/jsonfile/index.js. Jest's defaultResolver finds the file without problems.

@piranna
Copy link
Collaborator

piranna commented Apr 6, 2022

Pull Requests welcome.

@grpawel
Copy link

grpawel commented Apr 6, 2022

Looks like #12 attempts to fix the same issue. I've just tested it and it works in my case, no error on 'jsonfile'.

Those changes are also consistent with defaultResolver in https://github.com/facebook/jest/blob/main/packages/jest-resolve/src/defaultResolver.ts#L118

@gigaSproule
Copy link
Author

gigaSproule commented Apr 6, 2022

If the other PR is a better fix, go for it. I'll try and check it out to see if it also fixes our issue.

@grpawel
Copy link

grpawel commented Apr 7, 2022

@piranna If you would point out issues that prevent merging #12, I can fix them.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants