plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
436 stars 590 forks source link

Provide webpack config to allow testing components via Cypress #3844

Open tiberiuichim opened 1 year ago

tiberiuichim commented 1 year ago

Having a webpack config setup (the Volto specifics can be mostly extracted from the storybook configuration) would enable unit testing components via webpack.

tiberiuichim commented 1 year ago

https://github.com/cypress-io/cypress/tree/master/npm/webpack-preprocessor#options

tiberiuichim commented 1 year ago

https://docs.cypress.io/api/plugins/preprocessors-api#Defaults

davisagli commented 1 year ago

What's the benefit of unit testing via webpack instead of the status quo?

tiberiuichim commented 1 year ago

@davisagli testing with jest is fine for pure JS code, but I find that we don't do a good job with testing standalone components, because it's hard to model all the interactions of component. Maybe we should get more comfortable with react testing library, but, if you look in Volto's code, you won't find a single version of a "good jest test" for a component. We have a ton of bogus snapshots and our widgets are mocked in tests.

So, it would provide a middle ground between full and slow Cypress integration and faster, standalone component tests (I think storybook might have a test runner, we could look into that, as well).