diff --git a/.github/workflows/manual-test-matrix-workflow.yaml b/.github/workflows/manual-test-matrix-workflow.yaml index 00f2bec93..d09f3e84b 100644 --- a/.github/workflows/manual-test-matrix-workflow.yaml +++ b/.github/workflows/manual-test-matrix-workflow.yaml @@ -50,7 +50,7 @@ jobs: - name: "Setup NodeJS" uses: actions/setup-node@v4 with: - node-version: "16" + node-version: "22" - name: "Setup JDK" uses: actions/setup-java@v4 with: @@ -63,7 +63,7 @@ jobs: - name: Install Firefox uses: browser-actions/setup-firefox@v1 with: - firefox-version: "latest-esr" + firefox-version: "latest" - name: "Check docker status" run: systemctl status docker - name: "Run npm install" @@ -71,7 +71,7 @@ jobs: - name: "Run compile" run: "npm run compile" - name: "Run test(s)" - run: "cd packages/testsuite && npm test -- --browser=firefox --specs=cypress/e2e/${{ matrix.specs }}" + run: "cd packages/testsuite && npx cypress run --browser=firefox --spec=cypress/e2e/${{ matrix.specs }}" - name: "Archive test report(s) and video(s)" if: ${{ !cancelled() }} uses: actions/upload-artifact@v4 @@ -91,7 +91,7 @@ jobs: - name: "Setup NodeJS" uses: actions/setup-node@v4 with: - node-version: "16" + node-version: "22" - name: "Install necessary tools" run: npm install -g copyfiles gh-pages@3.0.0 mochawesome-merge mochawesome-report-generator - name: "Generate Mochawesome Report" diff --git a/.github/workflows/on-pull-request-workflow.yaml b/.github/workflows/on-pull-request-workflow.yaml index fa5ebcc6d..ab141e08d 100644 --- a/.github/workflows/on-pull-request-workflow.yaml +++ b/.github/workflows/on-pull-request-workflow.yaml @@ -14,7 +14,7 @@ jobs: - name: "Setup NodeJS" uses: actions/setup-node@v4 with: - node-version: "16" + node-version: "22" - name: "Setup JDK" uses: actions/setup-java@v4 with: @@ -38,4 +38,4 @@ jobs: run: | cd packages/testsuite SPECS=$(echo ${{ steps.changed-files-specific.outputs.all_changed_files }} | sed "s|packages/testsuite/||g") - KEYCLOAK_IMAGE=quay.io/keycloak/keycloak:24.0 npm run test-compiled -- --browser=chrome --specs=$SPECS + KEYCLOAK_IMAGE=quay.io/keycloak/keycloak:24.0 npx cypress run --browser=chrome --spec=$SPECS diff --git a/.github/workflows/reusable-build-project-workflow.yaml b/.github/workflows/reusable-build-project-workflow.yaml index 01198d10d..bcacbc122 100644 --- a/.github/workflows/reusable-build-project-workflow.yaml +++ b/.github/workflows/reusable-build-project-workflow.yaml @@ -16,7 +16,7 @@ jobs: - name: "Setup NodeJS" uses: actions/setup-node@v4 with: - node-version: "16" + node-version: "22" - name: "Setup JDK" uses: actions/setup-java@v4 with: @@ -29,7 +29,7 @@ jobs: - name: Install Firefox uses: browser-actions/setup-firefox@v1 with: - firefox-version: "latest-esr" + firefox-version: "latest" - name: "Run npm install" run: "npm install" - name: "Run compile" @@ -39,4 +39,4 @@ jobs: run: "cd packages/testsuite && npm test" - name: "Run specific test" if: "${{ github.event.inputs.spec != '' }}" - run: "cd packages/testsuite && npm test -- --specs=${{ inputs.spec }}" + run: "cd packages/testsuite && npx cypress run --spec=${{ inputs.spec }}" diff --git a/.github/workflows/scheduled-run-all-tests-workflow.yaml b/.github/workflows/scheduled-run-all-tests-workflow.yaml index 48d35f6a2..b6ab2dd36 100644 --- a/.github/workflows/scheduled-run-all-tests-workflow.yaml +++ b/.github/workflows/scheduled-run-all-tests-workflow.yaml @@ -50,7 +50,7 @@ jobs: - name: "Setup NodeJS" uses: actions/setup-node@v4 with: - node-version: "16" + node-version: "22" - name: "Setup JDK" uses: actions/setup-java@v4 with: @@ -63,7 +63,7 @@ jobs: - name: Install Firefox uses: browser-actions/setup-firefox@v1 with: - firefox-version: "latest-esr" + firefox-version: "latest" - name: "Check docker status" run: "systemctl status docker" - name: "Run npm install" @@ -71,7 +71,7 @@ jobs: - name: "Run compile" run: "npm run compile" - name: "Run test(s)" - run: "cd packages/testsuite && npm test -- --browser=chrome --specs=cypress/e2e/${{ matrix.specs }}/*.cy.ts" + run: "cd packages/testsuite && npx cypress run --browser=chrome --spec=cypress/e2e/${{ matrix.specs }}/*.cy.ts" - name: "Archive test report(s) and video(s)" if: ${{ !cancelled() }} uses: actions/upload-artifact@v4 @@ -91,7 +91,7 @@ jobs: - name: "Setup NodeJS" uses: actions/setup-node@v4 with: - node-version: "16" + node-version: "22" - name: "Install necessary tools" run: npm install -g copyfiles gh-pages@3.0.0 mochawesome-merge mochawesome-report-generator - name: "Generate Mochawesome Report" diff --git a/README.md b/README.md index 0974e1a11..28e297ea2 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ TestContainers (https://github.com/testcontainers/testcontainers-node) serves to Following tools are required to run the test suite - [NodeJS](https://nodejs.org/en/) as a runtime environment - - recommended version is 16, in other versions you can get errors like `Unable to detect compiler type` + - recommended version is 22 - [Node Version Manager (nvm)](https://github.com/nvm-sh/nvm) is recommended optional tool to install & manage multiple Node environments - [npx](https://github.com/npm/npx) CLI tool used to exeute binaries from project's `node_modules` directly (instead of providing absolute/relative path to the commannds). It is used in multiple build steps. - [Podman](https://podman.io) | [Docker](https://www.docker.com) as a container runtime used by TestContainers. Note that when using Podman as container runtime you may need to export following environment variables and start podman socket: @@ -54,15 +54,21 @@ npm run develop ``` - If you want to execute whole testsuite, navigate to `packages/testsuite` and from within that directory execute `npm test` + - It is also possible to run on specific browser by supplying `--browser` argument, e.g + ``` - npm test -- --browser=chrome + npx cypress run --browser=chrome ``` + - It is also possible to reduce the amount of specs executed by passing `--specs` flag. This flag must be relative to the `packages/testsuite` directory and supports glob patterns, e.g to execute only `ejb` related tests, run + ``` - npm test -- --specs="cypress/e2e/ejb/*.cy.ts" + npx cypress run --spec="cypress/e2e/homepage/*.cy.ts" ``` + - If you wish to run the test suite against custom HAL or WildFly images, you can use `HAL_IMAGE` and `WILDFLY_IMAGE` environment variables to specify custom images, e.g + ``` HAL_IMAGE=quay.io/myorg/hal WILDFLY_IMAGE=quay.io/myorg/wildfly npm test ... ``` diff --git a/package.json b/package.json index 6f20f3230..896f17d0f 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,9 @@ "@types/portscanner": "2.1.1", "@typescript-eslint/eslint-plugin": "5.55.0", "@typescript-eslint/parser": "5.55.0", - "axios": "1.3.4", + "axios": "^1.11.0", "copyfiles": "2.4.1", + "cypress": "^15.2.0", "del": "7.0.0", "del-cli": "5.0.0", "eslint": "8.36.0", @@ -39,7 +40,7 @@ "mochawesome-merge": "4.3.0", "mochawesome-report-generator": "6.2.0", "prettier": "2.8.5", - "testcontainers": "10.2.1", + "testcontainers": "^10.28.0", "typedoc": "0.23.28", "typescript": "5.0.2" }, diff --git a/packages/testsuite/cypress/e2e/update-manager/test-configuration-update-channel.cy.ts b/packages/testsuite/cypress/e2e/update-manager/test-configuration-update-channel.cy.ts index 519ce10d3..94d52ff4c 100644 --- a/packages/testsuite/cypress/e2e/update-manager/test-configuration-update-channel.cy.ts +++ b/packages/testsuite/cypress/e2e/update-manager/test-configuration-update-channel.cy.ts @@ -86,7 +86,7 @@ describe("TESTS: Update Manager => Channels", () => { it("Update url channel parameters", () => { cy.navigateToSpecificChannel(managementEndpoint, channels.url.name); cy.editForm(channelForm); - cy.get(".tm-tag-remove").click() + cy.get(".tm-tag-remove").click(); cy.formInput(channelForm, "repositories") .type(channels.updateUrl.repositories + "{enter}") .trigger("change"); diff --git a/packages/testsuite/open-cypress.ts b/packages/testsuite/open-cypress.ts index 926014602..97241cbb4 100644 --- a/packages/testsuite/open-cypress.ts +++ b/packages/testsuite/open-cypress.ts @@ -2,18 +2,33 @@ import * as cypress from "cypress"; import { Berg } from "@berg/berg"; -(async () => { - const berg = await Berg.getInstance(); - await cypress.open({ - env: { - NETWORK_NAME: berg.getNetwork().getName(), - HAL_CONTAINER_PORT: berg.getHalContainer().getMappedPort(9090), - }, - config: { - e2e: { - baseUrl: `http://localhost:${berg.getHalContainer().getMappedPort(9090)}`, - }, - }, - }); - await berg.stop(); +(() => { + Berg.getInstance() + .then((berg) => { + console.log("Processing the open-cypress.ts"); + console.log("Network :" + berg.getNetwork().getName()); + cypress + .open({ + env: { + NETWORK_NAME: berg.getNetwork().getName(), + HAL_CONTAINER_PORT: berg.getHalContainer().getMappedPort(9090), + }, + config: { + e2e: { + baseUrl: `http://localhost:${berg.getHalContainer().getMappedPort(9090)}`, + }, + }, + }) + .then(() => { + berg.stop().catch((exception) => { + console.log(exception); + }); + }) + .catch((exception) => { + console.log(exception); + }); + }) + .catch((exception) => { + console.log(exception); + }); })(); diff --git a/packages/testsuite/package.json b/packages/testsuite/package.json index a4b68e806..ee6f2f526 100644 --- a/packages/testsuite/package.json +++ b/packages/testsuite/package.json @@ -8,6 +8,7 @@ "dependencies": { "@berg/berg": "^1.0.0", "@berg/commands": "^1.0.0", + "axios": "1.11.0", "wait-port": "^1.0.4" }, "scripts": { @@ -21,7 +22,7 @@ "@types/command-line-args": "5.2.0", "@types/mochawesome": "6.2.1", "command-line-args": "5.2.1", - "cypress": "12.8.1", + "cypress": "^15.2.0", "cypress-multi-reporters": "1.6.3", "mocha-junit-reporter": "2.2.0", "mochawesome": "7.1.3", diff --git a/packages/testsuite/run-e2e-tests.ts b/packages/testsuite/run-e2e-tests.ts index aca8da4eb..f7ad62e03 100644 --- a/packages/testsuite/run-e2e-tests.ts +++ b/packages/testsuite/run-e2e-tests.ts @@ -1,5 +1,5 @@ import { Berg } from "@berg/berg"; -import * as cypress from "cypress"; +import cypress from "cypress"; import commandLineArgs from "command-line-args"; import { OptionDefinition } from "command-line-args"; @@ -12,25 +12,42 @@ const optionDefinitions: OptionDefinition[] = [ }, ]; -(async () => { +() => { const options = commandLineArgs(optionDefinitions); + console.log("Processing the run-e2e-test.ts"); console.log(options); - const berg = await Berg.getInstance(); - const testRunResult = await cypress.run({ - browser: options.browser as string, - env: { - NETWORK_NAME: berg.getNetwork().getName(), - HAL_CONTAINER_PORT: berg.getHalContainer().getMappedPort(9090), - }, - config: { - e2e: { - baseUrl: `http://localhost:${berg.getHalContainer().getMappedPort(9090)}`, - specPattern: (options.specs as string).split(","), - }, - }, - }); - await berg.stop(); - if (testRunResult.status == "failed" || testRunResult.totalFailed > 0) { - process.exit(1); - } -})(); + Berg.getInstance() + .then((berg) => { + cypress + .run({ + browser: options.browser as string, + env: { + NETWORK_NAME: berg.getNetwork().getName(), + HAL_CONTAINER_PORT: berg.getHalContainer().getMappedPort(9090), + }, + config: { + e2e: { + baseUrl: `http://localhost:${berg.getHalContainer().getMappedPort(9090)}`, + specPattern: (options.specs as string).split(","), + }, + }, + }) + .then((testRunResult) => { + berg + .stop() + .then(() => { + console.log(testRunResult); + process.exit(1); + }) + .catch((exception) => { + console.log(exception); + }); + }) + .catch((exception) => { + console.log(exception); + }); + }) + .catch((exception) => { + console.log(exception); + }); +};