Gitlab CI/CD: TypeScript/Cypress/Cucumber

Generate new project in your workspace
Make sure that Node.js is installed
Install Cypress with TypeScript: “npm install --save-dev typescript” it will result in the following structure:
Copy the following dependencies on your package.json:
Run npm install to install the latest versions of the dependencies.
Write a test case using Gherkin syntax and create additional file with Steps Definition. Place both files under /Cypress/e2e/ project folder:
For automation purpose let's assume that the .feature name is based on the actual aqua Test Case Id: e.g in the case above we updated aqua Test Case with Id=270.
Our simple 270.feature file looks as follows:
Steps Definition 270.ts file looks as follows:
Navigate to your cypress.config.ts file and put the following content into it:
Now we need to update aqua Test Case Execution based on the result of the Cypress/Cucumber feature run. To make it general and executable for all cases we will add “AfterEach” hook block in support file: …/cypress/support/e2e.ts:
For the above API request we need to know test case execution status from Cypress. This is being done by “cy.currentTest.state”.
To update aqua with Test Case Execution info we also need to provide aqua Test Case Id: in the above example test case id is extracted from “Number(Cypress.spec.fileName)”.
Classes we use for API calls can be generated from JSON schema available here: https://app.aqua-cloud.io/aquaWebNG/swagger/v1/swagger.json
After successful JUnit test execution we should see corresponding single Test Case execution in aqua
To be able to run the above Cypress/Cucumber Project using GitLab CI/CD we need to create corresponding workflow file .gitlab-ci.yml. Simple Example of .gitlab-ci.yml script is shown below:
Once a GitLab test runner is configured and connected to your GitLab projects we can Run GitLab Pipeline using the above workflow:
Link to GitLab Repository - https://gitlab.com/aqua3191704/cypress-typescript-gitlab.git (branch ‘Cucumber’)
Last updated
Was this helpful?