What would be the best way to inject custom script tag into head/page for tests only?
I'm writing feature specs with capybara, and I need to mock some 3-rd party api calls in the browser, I need to inject javascript code.
I tried to page.execute_script
, but it was too late. 3-rd party api calls are executed immediately on DOM ready. So I need to mock things before DOM ready.
I have some ideas, but I wonder what would be the best way?
Similar questions without answers: