I am trying to set up an acceptance test for an ember application that is using ember-cli-mirage
The doc says that server is supposed to be a global if you are in an acceptance test, but that is not working for me.
You can see the test/code here https://github.com/chrisortman/ember-cms-frontend/blob/master/tests/acceptance/consent-document-test.js#L7
I managed to make it start working.
I had to qualify my usage of server with window.server
https://github.com/chrisortman/ember-cms-frontend/commit/548189a18e472402def2b69881219e7c2519e0e5
EDIT
It works when I run the tests in browser with the /tests url, but not when using ember test or ember test --server
EDIT2
Seems due to a bug, but if you specify something for your host values it works
https://github.com/chrisortman/ember-cms-frontend/commit/745e28c3feafeee8b5f7f0faa7a554b0a364fd52
Related
Background:
I have a rails application with cucumber installed. I would like to use the cucumber tests associated to test the application deployed on a seperate system.
Problem:
So basically I have the URL for the deployed app and the cucumber tests, so when I start the cucumber with the app link as argument - I require cucumber to start the tests without invoking the rails app it is residing with but test the external link.
Why the need:
Cucumber always try to invoke the postgres database which is causing a problem for me as I am trying to dockerise it and I do not want to include postgres in it(for some reasons that is out of scope here).
So, is it possible to make it happen? (Running cucumber without invoking the other things like the app/call to db)
this can be achieved by defining a rack app that acts as proxy(routing to the endpoint that you want) in your rails app.
Example:
class TestAppRoutes < Sinatra::Application
uri = URI.parse("http://10.0.0.0")
get '/*' do
request_url = "#{uri}/#{params['splat'][0]}"
response = Net::HTTP.get(URI.parse(request_url))
response
end
end
And then define a ruby file in the features/support to instantiate the rack app:
if ENV['BASE_URL']
Lookout::Rack::Test.app = APP::TestAppRoutes
end
finally when you are invoking cucumber : do cucumber BASE_URL=http://10.10.10
checkout: https://github.com/lookout/lookout-rack-test
With RSpec, I'm trying to test a Rails program that calls an external python script. When running the spec, RSpec has access to the test database rails_program_test. However, the python script cannot access the database rails_program_test.
Furthermore, while running rails console test in a separate terminal, queries show no records in the test database, even though the spec reports that records do exist. Finally, when I switch the RAILS_ENV to development, the python script has access to the rails_program_development database. Is there a way to access the test database outside of the spec?
This may be because the Rails app is using transactional fixtures. They are rolled back at the end of each test, so are never visible to external processes.
You might want to look at the DatabaseCleaner gem for a non-transactional approach, but your use case sounds very unusual.
I am facing a problem running selenium tests with CircleCI service. If I try to test my ruby application's login functionality:
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://0.0.0.0:3000"
driver.find_element(:name, 'user[email]').send_keys('eser#email.com')
driver.find_element(:name, 'user[password]').send_keys('password')
driver.find_element(:name, 'commit').click
On local machine it works perfectly, but with CircleCI test fails. To be more specific, looks like on CircleCI my tests cannot access localhost (tried curl localhost:3000 in CircleCI test box - nothing found). I also tried changing 0.0.0.0 to localhost as well as to 127.0.0.1 - still same result. If I try very similar test for testing google's search (driver.navigate.to "http://www.google.com", etc.) it works with no problem. Tried to contact CircleCI - no response so far. Any ideas how to get my test pass, or at least how to get my application address when it is on CircleCI server?
In order to run tests, you need to have a selenium grid up and running. It works locally, because your box can run selenium tests.. CircleCI cannot run tests, it's just a CI.
What you need to do, is in your project, have your selenium tests point at a grid.
http://somegrid:4444/wd/register
I've noticed that when I run tests (using Rspec and spork, if that matters), my hostname is set to www.example.com. So if I do:
visit sports_url
the test is actually going to www.example.com/sports.
This is a problem because I need to run some of the tests with selenium (to get javascript support). Also, I noticed my emails where being marked as coming from www.example.com.
What did I mess up? Why is the test environment running as example.com? Can I configure this somewhere? I would assume it should be programatic (depending on what port the test server starts up on).
You can configure the test environment domain, then set up DNS to do what you need.
How do I change the default "www.example.com" domain for testing in rails?
So I do testing rspec+capybara on localhost, but if I wanted to test on staging server(linux), is it possible to use capybara?
I'm guessing testing with selenium will not work on staging server.
I would like to test frontend(mostly js stuff) on staging, any recommendation would be great.
I use Rails 3.
Checkout the headless gem - From the author
I created it so I can run Selenium tests in Cucumber without any shell scripting. Even more, you can go headless only when you run tests against Selenium.
I'd imagine it would would with rspec as well.