July 6, 2021

Cypress Component Testing with Next and Webpack 5

I was trying to setup component testing in Cypress this morning and I ran into the error Cannot read property 'version' of undefined. I tried various searches on Google but didn't find any solutions but when I searched directly in the issues on Cypress I finally found the answer. So I'm mainly writing this to give the post some jucie so that other finds it and can solve the issue.

The TL:DR solution is that you need to add the html-webpack-plugin to your package.json.

"html-webpack-plugin": "^5.3.1"

As usual with these complex webpack configs there are some kind of conflict and well, it's a miracle that anything works tbh. I'm old enough to remember the classic DLL-hell in Windows in the 90's and well and it's funny that nothing have changed :)

More info about this in this Github Issue and also a more detailed blog post on how to setup Component Testing in Next / Cypress.

© Copyright 2024 AlternativeTo . Powered with by CreativeDesignsGuru