Closed patrickclery closed 2 years ago
How are your Rails, React, and test suites set up, repo-wise? Can you share your RSpec and Capyabra configurations and a sample spec?
If you're using Chromedriver it may be due to it not using the Puffing Billy proxy for localhost requests. You'll need to configure Capybara's driver definition with --proxy-bypass-list=<-loopback>
.
For example, here's the current definition within Puffing Billy (lib/billy/browsers/capybara.rb) updated with the argument:
::Capybara.register_driver :selenium_chrome_billy do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--ignore-certificate-errors')
options.add_argument("--proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}")
options.add_argument("--proxy-bypass-list=<-loopback>") # New argument here to ensure requests to localhost are sent to Puffing Billy's proxy
::Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: options,
clear_local_storage: true,
clear_session_storage: true
)
end
There's likely an opportunity here for updating related configuration options (whitelist). I'm not yet familiar enough with the codebase to propose something specific but will do so if the opportunity arises.
Hello I also need help with a similar issue, we have an Angular app however none of the frontend backend interactions are being picked up by puffing billy so we can see the result of those responses in our capybara tests
@patrickclery were you able to make it work?
Stale issue, closing. Feel free to reopen if this is still desired.
Is it possible to use puffing-billy to stub requests to the local Rails API?
For example, I have a React app that I'd like to test with Capybara. It interacts with the API via
fetch
like so:Adding a stub for
proxy.stub("/api/v1/todos" ...
doesn't seem to work. There used to be an option forBilly.config.ignore_localhost = true
but that seems to be removed, and I'm not sure if this is even what I'm trying to achieve.My goal is to test my React front-end with Capybara/RSpec, without having to structure my project to use Jest/Enzyme/etc to test. I've already been able to do a Capybara test, but I can't stub the API requests (it uses the real test-server API)
Any suggestions welcomed :) Thanks