cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.72k stars 3.16k forks source link

Get Webpack Compilation Error on nextjs test with component-level css #9690

Closed yrue closed 1 year ago

yrue commented 3 years ago

Hi,

We have a nextjs project and using component-level css. I tried with the nextjs sample and it works. But it got error as below when importing import styles from './<component>.module.scss';. Looks mini-css-extract-plugin issue and the log similar to https://github.com/nrwl/nx/issues/2174. Any idea?

Error: Webpack Compilation Error
./components/Search.module.scss
Module build failed (from /Users/eur/Desktop/dev_uba/cypress-react-unit-test/node_modules/@zeit/next-css/node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: this[MODULE_TYPE] is not a function
 @ ./components/Search.jsx 5:0-42
 @ ./cypress/components/Search.spec.jsx

Reproduce repo: https://github.com/yrue/cypress-react-unit-test/tree/issue

  1. add "nodeVersion": "system" to cypress.json
  2. add scss file cypress-react-unit-test/examples/nextjs/components/Search.module.scss
  3. add import styles from './Search.module.scss'; to cypress-react-unit-test/examples/nextjs/components/Search.jsx
  4. run npm test and got error
cypress-app-bot commented 1 year ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot commented 1 year ago

This issue has been closed due to inactivity.

testplop commented 1 year ago

Still a issue

nagash77 commented 1 year ago

Hi @testplop please open a new issue with a reproducible example and the Cypress team will be happy to investigate.