This document serves as a comprehensive guide for running tests in the gitlab-org/gitlab-discussions- project. Ensure all dependencies are satisfied and that you have the necessary environment set up before executing the tests.
Prerequisites
Before running tests, make sure you have the following:
Ruby version 2.7.x or higher.
Bundler installed. Use the command:
gem install bundler
Node.js and Yarn installed for JavaScript dependencies.
Setting Up the Environment
Clone the Repository: Clone the repository using:
git clone https://gitlab.com/gitlab-org/gitlab-discussions-.git cd gitlab-discussions-
Install Ruby Dependencies: Run the following command to install the Ruby gems required by the project:
bundle install
Install JavaScript Dependencies: Ensure you have Yarn installed, then run:
yarn install
Running Tests
The tests are organized mainly into RSpec for Ruby and Jest for JavaScript. Follow the steps below to run both sets of tests:
Running Ruby Tests
Execute RSpec Tests: The Ruby tests can be run using RSpec. Execute the following command to run all RSpec tests:
bundle exec rspec
To run a specific test file, use:
bundle exec rspec spec/path/to/your_test_spec.rb
Running JavaScript Tests
Execute Jest Tests: To run the JavaScript tests using Jest, use the command:
yarn test
You can also run only the changed tests by using:
yarn test --watch
Debugging Tests
If you encounter any test failures, you can debug using the following steps:
- Re-run the specific tests using the commands listed above.
- Enable debug logs by setting the
DEBUG
environment variable:DEBUG=1 bundle exec rspec
For detailed output in the JavaScript tests, use:
yarn test --verbose
Running Tests in Parallel (Optional)
For improved performance, you can run RSpec tests in parallel. First, add parallel_tests
to your Gemfile:
gem 'parallel_tests'
Then run:
bundle install
bundle exec parallel_test spec/
Additional Notes
- Ensure that your test environment is correctly set up. Check the
.env.sample
file for environment variable configurations that may be required for testing. - Review the test cases and their configurations in the
spec
andtests
directories for a better understanding of the testing framework used.
By following these steps, you should be able to run all tests for the gitlab-org/gitlab-discussions- project successfully. For further information, consult the documentation available within the project repo.
Source: Documentation generated from the project’s internal guidelines.