gregberge / loadable-components

The recommended Code Splitting library for React ✂️✨
https://loadable-components.com
MIT License
7.7k stars 381 forks source link

Add more comprehensive testing #930

Closed fivethreeo closed 1 year ago

fivethreeo commented 1 year ago

After adding a feature pull request a need for more comprehensive testing manifested itself. Was thinking I could try setting up some tests with react-testing-library. @theKashey suggested testing with a webpack build aswell.

Adding this issue to start a discussion about how best to do that.

fivethreeo commented 1 year ago

Trying to set up cypress with webpack to test components. But it does not accept array webpack configuration. So maybe use patch-package to add that or go with another solution.

fivethreeo commented 1 year ago

Some progress, but not sure cypress is the right way to go https://github.com/fivethreeo/loadable-components/tree/testing/cypress/examples/server-side-rendering

fivethreeo commented 1 year ago

Selenium is a better solution for testing https://github.com/fivethreeo/loadable-components/blob/testing/selenium/examples/server-side-rendering/__tests__/selenium-test.js

theKashey commented 1 year ago

You are mixing Cypress component testing with Selenium e2e testing. Try Cypress e2e or Playwring e2e. Ie the "classic" modes when the test suite is used against another running artefact.

fivethreeo commented 1 year ago

Ah, duh :) Cypress , playwright or selenium, any preferences?

fivethreeo commented 1 year ago

By the way, I could move the loadable monorepo over to pnpm if you want. A lot faster and the examples don't need to clear out node_modules when packages rebuild.

fivethreeo commented 1 year ago

Cypress e2e seems good. Just need a test strategy. Maybe add a window method to kick off loading and hydration.

theKashey commented 1 year ago

I see two strategies:

In both cases feel free to export required commands to window and call them directly from Cypress.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.