Help Center

Local testing

Written by Miguel Michelson


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 dependencies, so let's do that.

Install dependencies

(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 the test suite. note that there are unit tests 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 model's 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 tell 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 where you can manually run specific specs or the entire suite.
Also, you can run this test suite as a headless process with won't require the Cypress panel with the following command

 yarn cypress run

So that's it, happy testing!