question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React.lazy component test errors

See original GitHub issue

Current behavior

I have a simple spec that lazy loads a component (followed the example outlined in the lazy-load advanced examples) which fails to compile correctly with the following error:

The following error originated from your test code, not from Cypress.

  > Automatic publicPath is not supported in this browser

I’ve tried to re-set up the whole environment to mirror, as closely as possible, the example link from above. Of note is that I’m using cypress-webpack-preprocessor-v5 instead of what is provided in the example as, subsequently, thats what my project is using as well.

If I comment out the Bar lazy load on line 3 of src/Foo.js and the usage of <Bar /> on line 8, the test compiles correctly. I’ve attached a zip file mirroring the whole setup. After downloading, run the following:

  • npm i
  • npm test

Desired behavior

The test should pass.

Test code to reproduce

See attached zip file.

cypress-i18n.zip

Versions

“cypress”: “^6.5.0”, “@cypress/react”: “^5.0.0”, “cypress-webpack-preprocessor-v5”: “^5.0.0-alpha.1”, “webpack”: “^5.22.0”,

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Apr 27, 2021

Closing as resolved.

If you’re experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

0reactions
sethomascommented, Apr 27, 2021

This is no longer an issue with the below deps on webpack 5:

"@cypress/code-coverage": "3.9.5",
"@cypress/react": "5.4.0",
"@cypress/webpack-dev-server": "1.1.5",
"cypress": "7.2.0",
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Testing Library - Lazy Loading - Error act()
When I remove from the a component which uses react lazy loading the error message goes away. So how can I test over...
Read more >
Test components that use React.lazy + Suspense - YouTube
Test components that use React. lazy + Suspense ... This was something I bumped into yesterday and thought I'd share how I test...
Read more >
Code-Splitting - React
Once you've created your Error Boundary, you can use it anywhere above your lazy components to display an error state when there's a...
Read more >
React Lazy Loading: The Best Complete Guide - CopyCat Blog
Learn how to optimize your app with a complete guide to React lazy loading and code splitting with coding examples, tips, videos, and...
Read more >
Test components that use React.lazy + Suspense
Test components that use React.lazy + Suspense · My OSS git workflow · My Pull Request Review/Merge Workflow · React Hooks: useImperativeHandle ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found