Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in absolute file path of component-index.html #27750

Closed
wiegell opened this issue Sep 5, 2023 · 7 comments · Fixed by #28324
Closed

Error in absolute file path of component-index.html #27750

wiegell opened this issue Sep 5, 2023 · 7 comments · Fixed by #28324
Labels
CT Issue related to component testing

Comments

@wiegell
Copy link

wiegell commented Sep 5, 2023

Current behavior

This issue tried to solve the resolution of component-index.html:
#26400

However the problem is still present. When setting:

  component: {
    indexHtmlFile: <SOME ABSOLUTE PATH>,
  }

You get an error along the lines of:

ERROR in   Error: Child compilation failed:
  Module not found: Error: Can't resolve 'USERHOME/cypress-example/  someorg/libs/my-standalone-lib/USERHOME/cypress-example/someorg/li  bs/my-standalone-lib/cypress/support/component-index.html' in '/USERHOME/t  rifork/cypress-example/someorg'
  ModuleNotFoundError: Module not found: Error: Can't resolve '/USERHOME/cypress-example/someorg/libs/my-standalone-lib/USERHOME/cypre  ss-example/someorg/libs/my-standalone-lib/cypress/support/component-index.html  ' in '/USERHOME/cypress-example/someorg'

The problem is resolved if instead you use a relative path to the component-index.html:

  component: {
    indexHtmlFile: './cypress/support/component-index.html',
  },

The issue is bad because nx uses an absolute path, so no component testing is working via nx

Desired behavior

No response

Test code to reproduce

Repro:
https://github.com/wiegell/cypress-bug
Run:
yarn nx run my-standalone-lib:component-test

This repro has been made with:

  • Fresh nx repo
  • Generated standalone angular component via nx
  • Generated nx component testing into that lib via nx

Cypress Version

13.1.0, also tried 12.17.4, same problem.

Node version

v18.17.1

Operating System

macos 13.4.1

Debug Logs

gist

Other

No response

@wiegell
Copy link
Author

wiegell commented Sep 5, 2023

@lmiller1990 sorry for the ping, but since you solved the original issue you might find this relevant.

@nagash77 nagash77 added the CT Issue related to component testing label Sep 6, 2023
@lmiller1990
Copy link
Contributor

lmiller1990 commented Sep 6, 2023

Thanks for filing this issue. I'm not working on Cypress any more, so I'm not sure I'll be able to look at this one in the immediate future. It should be a reasonably easy fix though, take a look at the previous PR and see if we can check if it's absolute path, and handle that correctly.

@Roemer
Copy link
Contributor

Roemer commented Nov 13, 2023

Is this working with Cypress 12.17.3? We have a very similar issue, where we define the indexHtmlFile like: indexHtmlFile: __dirname + '/cypress/support/component-index.html' which seems to work up until 12.17.3 and now with 12.17.4 or higher it fails because it tries to lookup the component-index.html in a combined path from the current project + the absolute path from our config.

@Roemer
Copy link
Contributor

Roemer commented Nov 13, 2023

After further analysis, the fix from #26400 actually introduced this bug.
The fix just plain simply joins the project path and the defined file path, if it happens to be absolute, it just breaks.

@lstkz
Copy link

lstkz commented Nov 13, 2023

I have the same issues. Upgraded from v10 to v13.5.

indexHtmlFile throws error

indexHtmlFile: path.join(__dirname, 'cypress/index.html'),

supportFile works in the same way

supportFile: path.join(__dirname, 'cypress/support.js'),

@Roemer
Copy link
Contributor

Roemer commented Nov 13, 2023

I created a very simple fix for it in the PR: #28324 but I could not yet test it.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 21, 2023

Released in 13.6.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.6.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CT Issue related to component testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants