-
Notifications
You must be signed in to change notification settings - Fork 49
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
raise error if baseUrl is set and not supported #26
raise error if baseUrl is set and not supported #26
Conversation
@@ -24,7 +24,28 @@ def determine_new_config(config_path) | |||
end | |||
|
|||
def merge_existing_with_defaults(json_path) | |||
Hash[JSON.parse(File.read(json_path)).merge(DEFAULT_CONFIG).sort] | |||
existing = JSON.parse(File.read(json_path)) | |||
base_url = existing["baseUrl"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a lot more things to be checked here, but I figured I'd stop at path and scheme just to demonstrate the idea
There are a few complicating factors to all this that apply to either approach, which is that there are multiple ways a user can change the base URL
All of this suggests to me that what I'd probably rather do is avoid getting cute about interpreting how a user has configured cypress and instead expose a new configuration flag for cypress-rails that sets either the BASE_URL or, even easier, BASE_URL_PATH which we'd then tack on to our existing constructed-URL. This both saves on the complexity of this gem (wherein cypress is always going to be a moving target) and also gives users maximum control over the behavior that they want (at the expense of having to read the documentation if things don't work for them) If you think this |
Yeah, I see what you mean. My other idea was to put a diff --git a/lib/cypress-rails/launches_cypress.rb b/lib/cypress-rails/launches_cypress.rb
index 83986c2..fcf2865 100644
--- a/lib/cypress-rails/launches_cypress.rb
+++ b/lib/cypress-rails/launches_cypress.rb
@@ -27,9 +27,9 @@ module CypressRails
set_exit_hooks!(config)
- system <<~EXEC
- CYPRESS_BASE_URL=http://#{server.host}:#{server.port} "#{bin}" #{command} --project "#{config.dir}" #{config.cypress_cli_opts}
- EXEC
+ command = "CYPRESS_BASE_URL=http://#{server.host}:#{server.port} \"#{bin}\" #{command} --project \"#{config.dir}\" #{config.cypress_cli_opts}"
+ puts "Launching Cypress with command '#{command}'"
+ system(command)
end
private In aide of making a simple change, maybe that's the way to go? Happy to make that PR |
Ok, I added the aforementioned option and released it in 0.3.0 (relevant commit here: 214d545 ) Let me know how that works for you, but I'll close unless I hear back that it's not working for you (I only tested locally, forgive me) (By the way, it occurred to me if you set |
Awesome, thanks! |
Heh, there's one more use case that this misses! I'm running against a react dev build, which I start in a harness that wraps cypress-rails. Or at least, I'm trying to get to wrap cypress-rails. I always am running against the same host (local), but usually have the backend on port 3000, and the dev build on 3001. |
Addresses #25
I could not find a good place to write the documentation that
baseUrl
would be ignored by this library, and digging I figured instead an error could be shown if thebaseUrl
was not compatible.This code is merely for discussion of this approach. I am not married to the way it's done as I did it as quickly as I could.
That said, I think a better change would be to modify https://github.com/testdouble/cypress-rails/blob/master/lib/cypress-rails/launches_cypress.rb to parse the baseUrl and use its parts.
The reason I didn't do that is that it's not clear to me if or how I should parse the
cypress.json
file. ShouldConfig
do this, or shouldLaunchesCypress
do this or what?So, thoughts on:
baseUrl
. If so, thoughts on where is most appropriate to accesscypress.json