Skip to content

Latest commit

 

History

History
69 lines (58 loc) · 1.93 KB

cypress-tests.md

File metadata and controls

69 lines (58 loc) · 1.93 KB

Cypress Tests

Contents

Setup

Versions used:

  • Node: 20.9.0
  • npm: 10.2.3
  • pnpm: 8.10.2

pnpm

Cypress setup use pnpm, you will first need to install it:

npm install -g pnpm

Then in the test/e2e folder, install the dependencies

pnpm install

cypress.config.ts

To configure cypress for you setup, modify cypress.config.ts.

export default defineConfig({
  e2e: {
    baseUrl: 'http://localhost:8080/',
    reporter: 'cypress-multi-reporters',
    reporterOptions: {
      configFile: 'reporter-config.json'
    }
  },
});

For example, if your Keycloak instance or container is not running on http://localhost:8080/, modify it.

Running the Cypress test

Cypress test are under a specific profile. To run them with maven use -P cypress-tests.
Example: maven clean test -P cypress-tests

Running with Cypress

After the setting up your environment and configuring your cypress.config.ts. You start cypress UI by executing the command

npx cypress open

in test/e2e folder.

You should get the Cypress UI.
cypress

Then, click on E2E Testing, choose the browser you want and click on Start E2E Testing in ....
After that, you can choose any *.cy.ts file in Specs to run the tests and debug.

Cypress Testcontainers

A Cypress testcontainers based on https://github.com/wimdeblauwe/testcontainers-cypress is used.
It populates dynamically the baseUrl with the Keycloak testcontainers instance and run all tests in the test/e2e folder.

To run the tests with the testcontainers, run the runCypressTests() in CypressOrganizationTest.java like any Junit test.