Testing COSMOS
Playwright
Prerequesits
-
Install pnpm
npm install --global pnpm@latest-10
-
Clone the COSMOS repo
git clone https://github.com/OpenC3/cosmos
-
Install Playwright and dependencies
cd cosmos/playwright
cosmos/playwright % ./playwright.sh install-playwright
Playwright Testing
-
Start COSMOS
cosmos % openc3.sh start
-
Open COSMOS in your browser. At the login screen, set the password to "password".
-
Run tests (Note the --headed option visually displays tests, leave it off to run in the background)
Tests are split into a group that runs in parallel and a group that runs serially. This is done to improve overall execution time.
cosmos/playwright % pnpm test:parallel --headed
cosmos/playwright % pnpm test:serial --headedYou can run both groups together, but the --headed option will not apply to both groups:
cosmos/playwright % pnpm test
-
[Optional] Fix istanbul/nyc coverage source lookups (use
fixwindows
if not on Linux).Tests will run successfully without this step and you will get coverage statistics, but line-by-line coverage won't work.
cosmos/playwright % pnpm fixlinux
-
Generate code coverage
cosmos/playwright % pnpm coverage
Code coverage reports can be viewed at cosmos/playwright/coverage/index.html
Ruby Unit Tests
-
Navigate to cosmos/openc3 folder. Run the command:
cosmos/openc3 % rake build
cosmos/openc3 % bundle exec rspec
Code coverage reports can be found at cosmos/openc3/coverage/index.html
Python Unit Tests
-
Navigate to cosmos/openc3/python folder. Run the command:
cosmos/openc3/python % python -m pip install poetry
cosmos/openc3/python % poetry install
cosmos/openc3/python % poetry run coverage run -m pytest
cosmos/openc3/python % poetry run coverage html
Code coverage reports can be found at cosmos/openc3/python/coverage/index.html