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.
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.
(make sure you are inside the chaskiq folder)
cd chaskiq bundle install
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.
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
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
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!