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

💚 Fixing unit tests #38

Merged
merged 3 commits into from
Sep 22, 2024

Conversation

VadimZvf
Copy link
Contributor

Unit tests don't pass in the master branch.
They fail with the next error:

  2) <ArrayGroup />
       ArrayGroup renders at root:
     TypeError: Cannot read properties of undefined (reading 'load')
      at render (/home/runner/work/react-json-view/react-json-view/node_modules/enzyme/build/render.js:38:31)
      at Context.<anonymous> (/home/runner/work/react-json-view/react-json-view/test/tests/js/components/ArrayGroup-test.js:99:31)
      at processImmediate (node:internal/timers:483:21)

This error happens because of a broken pear dependancy of enzyme.
Enzyme imports "cheerio" package and uses a default export 👉 here
But cheerio doesn't have any default export anymore 👉 here

The solution - update the enzyme version.

However, after the update we receive an another error. Enzyme imports some internal code from cheerio and it breaks the build.
The fix is to use a RC version of cheerio. Details - cheeriojs/cheerio#2547

Using latest version of enzyme with patched version of cheerio
Copy link

vercel bot commented Sep 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-json-view ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 22, 2024 3:35pm

@Kikobeats
Copy link
Member

@VadimZvf thanks for pushing this! I tried to update cheerio but tests are still failing, any idea why?

We should use exact cheerio version
@VadimZvf
Copy link
Contributor Author

@VadimZvf thanks for pushing this! I tried to update cheerio but tests are still failing, any idea why?

Oops... We should use exact version "~1.0.0-rc.3" → "1.0.0-rc.3"

Deps with "~1.0.0-rc.3"

npm list cheerio
@microlink/[email protected] /react-json-view
├── [email protected]
└─┬ [email protected]
  └── [email protected] deduped

With exact version "1.0.0-rc.3"

npm list cheerio
@microlink/[email protected] /react-json-view
├── [email protected]
└─┬ [email protected]
  └── [email protected] deduped

@VadimZvf
Copy link
Contributor Author

Also we should put it into devDependencies 😬

@Kikobeats Kikobeats merged commit cec1249 into microlinkhq:master Sep 22, 2024
3 checks passed
@Kikobeats
Copy link
Member

You fixed 🙌

@yehor-anisimov
Copy link

yehor-anisimov commented Oct 4, 2024

@VadimZvf Good job with locking "cheerio": "1.0.0-rc.3". It helped me on other project.

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

Successfully merging this pull request may close these issues.

3 participants