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

overwrites baseUrl? #25

Open
davetron5000 opened this issue May 12, 2020 · 3 comments
Open

overwrites baseUrl? #25

davetron5000 opened this issue May 12, 2020 · 3 comments

Comments

@davetron5000
Copy link

Migrating something to use this gem—which I am so thankful exists—and for no good reason, my baseUrl was not /, so my initial cypress.json was like this:

{
  "baseUrl": "http://localhost:3000/foo"
}

bin/rails cypress:init did not change that value, but when I run bin/rails cypress:run, my guess is that the "use some random port to run the rails app" does this by setting baseUrl to http://localhost:«that random port», thus making my tests fail. They use cy.visit("/") and were requesting / and not /foo, which is what the baseUrl should've been sending them to (note the tests worked if I ran rails on its own and did cypress run).

I changed all my cy.visit("/") to cy.visit("/foo"), and everything worked (and I should've done that anyway), but I guess what was surprising was that this gem means I cannot set baseUrl any longer. I think that is fine behavior, but maybe should be documented and/or output in some sort of log?

If agreed, I can fork the README and write what would've made this not surprising to me, but wanted to confirm that behavior first.

@searls
Copy link
Member

searls commented May 13, 2020

Sorry for the frustration, Dave! (👋 by the way)

I spent a few minutes trying to make sense of the code, but I can't confirm or deny the root cause at first glance. This server#base_url method would seem to confirm your point, but it's not referenced anywhere in the gem, so maybe it's actually dead code 😱

Would happily accept any PR that would either improve the documentation or the gem for others

@davetron5000
Copy link
Author

Looks like this is where that happens:

https://github.com/testdouble/cypress-rails/blob/master/lib/cypress-rails/launches_cypress.rb#L31

I guess I could've grep'ed that myself o_O

I will make two PRs, one for docs and one for logging this.

@searls
Copy link
Member

searls commented May 15, 2020

Fixed in 0.3.0 (see #26)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants