Skip to content

Testing

Dayne edited this page Mar 7, 2023 · 10 revisions

Ruby test stuff

Test setup

  • setup do
  • teardown do

Pegasus

Single unit test

RAILS_ENV=test bundle exec rake test:pegasus TEST=test/test_pegasus_documents.rb

UI Tests

Single UI Test File

pushd dashboard/test/ui; bundle exec ./runner.rb -l -f features/sometest.feature; popd

Something to try soon would be the following:

bundle exec rake test:ui feature=dashboard/test/ui/features/sometest.feature

Auto run tests on file change

UI Test

find . -type f \( -name "*.rb" -o -name "*.feature" \) | entr -scr 'pushd dashboard/test/ui; ./runner.rb -l --html --eyes -f features/markdown_rendering.feature; popd'

Workaround for MacOS

diff --git a/dashboard/test/ui/utils/selenium_browser.rb b/dashboard/test/ui/utils/selenium_browser.rb
index 3bbcd0a6eb5..004274811c2 100644
--- a/dashboard/test/ui/utils/selenium_browser.rb
+++ b/dashboard/test/ui/utils/selenium_browser.rb
@@ -7,6 +7,7 @@ module SeleniumBrowser
     options = {}
     case browser
     when :chrome
+      Selenium::WebDriver::Chrome.driver_path = "/Users/daycode/.webdrivers/chromedriver"
       options[:options] = Selenium::WebDriver::Chrome::Options.new
       options[:options].add_argument('headless') if headless
       options[:options].add_argument('window-size=1280,1024')

Dashboard test

find . -type f \( -name "*.rb" -o -name "*.feature" \) | entr -scr 'pushd dashboard; RAILS_ENV=test bundle exec spring testunit test/controllers/courses_controller_test.rb --name test_user_calling_get_index_should_receive_success; popd'

Javascript Tests

WATCH=1 BROWSER=Chrome LEVEL_TYPE='applab1' npm run test:integration --grep='ec_goals'

  • You may have to adjust applab1 or ec_goals.

Debugging

  • Add debugger; in the JS code.
    • You will need to right-click the chrome window and launch the debugger for the breakpoint to get hit though.

Errors

TODO get actual error

needs migrate 

Do this:

pushd dashboard; bundle exec rake db:migrate RAILS_ENV=test; popd

Clone this wiki locally