Sample project to experiment with Cypress to test the GitLab application.
You need to have a GitLab local environment such as GDK or Docker up and running.
You also need to have Node.js and npm installed on your computer.
For this project, the following versions of Node.js and npm were used:
$ node -v
v20.16.0
$ npm -v
10.9.0
Run docker run --publish 80:80 --name gitlab --hostname localhost wlsf82/gitlab-ce
and wait for the environment to be up and running (this might take a minute or so).
All should be ok if, when accessing the http://localhost/ URL, a form to define the password of the root
user is displayed.
❗THERE'S NO NEED TO DEFINE THE PASSWORD MANUALLY❗
There's an automated test for it. 😉
Keep reading.
Run npm i
to install the dev dependencies.
Before running the tests, create a file called
cypress.env.json
in the project root directory, based on thecypress.env.example.json
file, and update the value of theuser_password
property with one of your choice.By default, the tests will run against
http://localhost/
, but if you need to run them in a different URL (e.g.:http://localhost:3000/
), change thebaseUrl
property in thecypress.config.js
file.
Run npm test
to run all tests in headless mode.
Run npm run test:api
to run only the API tests in headless mode.
Run npm run test:gui:project:issue
to run only the GUI Project-issue-related tests in headless mode.
Run npm run test:gui:project:but:issue
to run only the GUI Project-but-issue-related tests in headless mode.
Run npm run test:gui:all:but:project
to run only the GUI Project-not-related tests in headless mode.
- Run
npm run cy:open
to open the Cypress App; - Select E2E Testing;
- Select one of the available browsers (e.g., Electron), and click the Start button;
- Run the
cypress/e2e/gui/profile/createAccessToken.cy.js
test; - Finally, click on the test file you want to run and wait for it to finish.
Important notes about the above steps
Do not skip step 4! It will authenticate the
root
user, create a GitLab Access Token, and make it available to all other tests while the Cypress App is kept open unless thecypress/e2e/gui/profile/deleteAccessTokens.cy.js
test is run. In such a case, thecypress/e2e/gui/profile/createAccessToken.cy.js
test needs to be re-run.Also, step 4 creates a session for the
root
user, which will be restored by most tests. This means that login via GUI should only happens once, speeding up the execution. 🏎️
Here's an example of running all the GUI tests in interactive mode.
index.cy.js.mp4
If you want to contribute to this project, follow the below steps.
- Fork the project;
- Clone your fork and make your changes;
- Test your changes locally, and move on only when all tests are green;
- Push your changes to GitHub and create a pull request (PR);
- After the GitHub Workflow of your PR is green, tag @wlsf82, ask for review and wait for feedback;
- If everything goes well, you should have your changes rebased and merged to the main branch. Otherwise, you will receive comments with adjustments needed before merging.
This is the commit messaging guidelines you should follow.
Developed with 💚 by Walmyr.