cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Components testing - webpack behaves differently based on location of config file

Open gsouf opened this issue 1 year ago • 0 comments

Current behavior

Cypress components testing won't behave the same way if the cypress config file is at the root of the app, or in a subdirectory. Relative paths are not managed the same way.

Here is what I noticed to be broken:

  • webpack entry is resolved relatively to cypress config's directory
  • babelrc/babel.config.json/`package.json>"babel" key, in the root directory are ignored
  • cypress/support/component-index.html is not resolved, it tries to resolve cypress/cypress/support/component-index.html (cypress is used twice).

Desired behavior

Works the same way no matter where the cypress config file is placed.

Test code to reproduce

Clone this repository, using branch cypress-components-path :

https://gitlab.com/souf/react-webpack-playground/-/tree/cypress-components-path

  • run yarn install

  • Try the working configuration when cypress config file is at the root: yarn cypress:root and click "component testing"

All is working well


  • Try the same config placed in a subdirectory (cypress/cypress.config.js): yarn cypress:subdir

Errors:

  • Module not found: Error: Can't resolve './src/index.jsx'
  • Module not found: Error: Can't resolve '......./cypress/cypress/support/component-index.html'

  • Try config placed in the sub directory but with webpack entry updated: yarn cypress:subdir2
  • syntax error because @babel/preset-react is not loaded (babelrc ignored)

Cypress Version

10.4.0

Other

Current fix - keep cypress config file in root directory

gsouf avatar Aug 09 '22 11:08 gsouf

won't behave the same way if the cypress config file is at the root of the app, or in a subdirectory. Relative paths are not managed the same way.

Sounds a bit same as #22689.

AriPerkkio avatar Aug 10 '22 08:08 AriPerkkio

Hey @gsouf, I am going to close this since it seems like #22689 should resolve this as well. Feel free to reopen this issue if that is not the case!

rockindahizzy avatar Aug 11 '22 14:08 rockindahizzy

@rockindahizzy thanks, any idea of an approx timespan to see this fixed?

gsouf avatar Aug 11 '22 21:08 gsouf