-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Cypress CT does not support ressources fetched from relative paths #26725
Comments
@lmiller1990 Have you encountered this problem before / thought about a solution? |
Hm, interesting idea - if it's a not breaking change, I think it'd be fine. Are you interested in making a PR? I'd like to see if anything fails. I will be out on vacation for a few weeks, but I'll do my best to give you some feedback during that time. You could also tag anyone in @cypress-io/component-testing if you need a review. |
I'll give it a try. When I had a closer look I noticed the header is actually parsed from the url, so just dropping it is not possible. However I could move the source into a query-param, sth like It's not super urgent, I worked around it for now with the header hack and we are migrating to my devserver, but would be nice to see this improved anyway. Also have a great vacation! |
@fochlac vacation was good, I will review your PR now, thanks for the patience. |
The code for this is done, but this has yet to be released. We'll update this issue and reference the changelog when it's released. |
Released in Cypress 13.0.0. |
Current behavior
Any relative request from inside a component test will include
/__cypress/iframe
and will therefore be mapped to/__cypress/src/index.html
and forwarded to the ct-dev-server. A header is provided including the original request path, however it would be quite hacky to use this to parse the relative path, as it would need to be matched against the test-file it was last called with.Desired behavior
Cypress should be able to distinguish between the initial request used to kickstart the test-runner that needs to be mapped to the index.html and subsequent relative requests, that need to be forwarded to the dev-server as relative requests.
i.e. a request to
./data/image.png
in a test with absolute pathc:/project/cypress/component/test.cy.jsx
currently resolves to/__cypress/iframe/c:/project/cypress/component/data/image.png
but should resolve to/__cypress/src/data/image.png
Test code to reproduce
I have a failing testcase in my custom dev-server here:
/~https://github.com/fochlac/cypress-ct-custom-devserver/blob/main/cypress/component/Test.cy.tsx#L13-L27
However I have also reproduced the issue using the webpack dev server in an private repository. Since the offending code is in the iframe controller this should also affect the vite-devserver:
/~https://github.com/cypress-io/cypress/blob/7630caed820c685295ff2fb52c98455ab0cf7bf6/packages/server/lib/controllers/iframes.ts#L44C1-L62
A workaround would be to use the
__cypress_spec_path
-header and match it against subsequent requests to properly map relative requests to the output folder, but that is super hacky.Cypress Version
12.x
Node version
16.16
Operating System
windows / unix
Debug Logs
Other
No response
The text was updated successfully, but these errors were encountered: