Help Center


Local testing

https://app.chaskiq.io/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbXdEIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--827f2d0b5794f7bb660c48b79e228655bd857bed/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2RkhKbGMybDZaVjkwYjE5c2FXMXBkRnNIYVdscGFRPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--cf24ea7784b3789671bb09c4029aca003c26b32d/me.jpg

Written by Miguel Michelson

updated

Once you are up and running with the installation of Chaskiq on development ( check getting started articles ) you will be able to run the application on development.

Setup test environment

In order to run the tests you will need to create the proper connections to the database and install the application dependences, so let's do that.

Install dependences

(make sure you are inside the chaskiq folder)

cd chaskiq
bundle install

Create database & load structure

bundle exec rails db:schema:load

Now you are ready to run test suite. note that there are unit tests on for the application that are pure Rspec tests for models, API, controllers & services. And there are integration (or end to end) tests implemented with Cypress which tests complete use cases from users's behavior on the UI's using automated Chrome.

Run Unit tests

The following will run all the tests excluding the End to end Cypress tests

bundle exec rspec

if you want to test only the models files you would run this: bundle exec rspec ./spec/models or files in controllers bundle exec rspec ./spec/controllers
you can find all the documentation of Rspec on Rspec's site

Run UI specs

To run End to End specs with Cypress you will need a couple more additional steps, nothing crazy though, remember that we are running on rails.

Step 1: install JS dependences
If you have not already done so, install the js dependencies with the yarn command

yarn install


Step 2: Run the rails server on port 5002 with a test flag
In order for Cypress to interact with Chaskiq app you will need to run the application on port 5002 but telling it that you are going to use the test environment with the following command

bundle exec rails server -e test -p 5002


Step 3: Run the cypress client
Last step you will need to run the cypress client with the following command

yarn cypress open --project ./spec

This command will open the Cypress panel were you can manually run specific specs or the entire suite.
Also you can run this test suite as headless process with won't require the Cypress panel with the following command

 yarn cypress run

So that's it, Have a happy testing!