Skip to content

Commit

Permalink
default video to false
Browse files Browse the repository at this point in the history
remove archive of screenshots
removed publishHTML
improved README.md
  • Loading branch information
roicarrera committed Dec 5, 2024
1 parent 1948dd2 commit c3d8976
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 32 deletions.
13 changes: 2 additions & 11 deletions e2e-cypress/Jenkinsfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def stageTest(def context) {
// making sure to include in the secret names the environment name in lowercase (e.g., e2e-user-dev, e2e-user-test,
// etc.), in case of using different secrets for different environments.
// Secrets in OpenShift need to be created with the credential.sync.jenkins.openshift.io=true label to be available in Jenkins.
// These are examples for loading credentials from the testing user for logging into your application.
withCredentials([
// usernamePassword(credentialsId: "${context.projectId}-cd-e2e-user", passwordVariable: 'CYPRESS_PASSWORD', usernameVariable: 'CYPRESS_USERNAME'),
// string(credentialsId: "${context.projectId}-cd-otp-secret", variable: 'OTP_SECRET')
Expand Down Expand Up @@ -119,26 +120,16 @@ def stageTest(def context) {
stash(name: "acceptance-test-reports-junit-xml-${context.componentId}-${context.buildNumber}", includes: 'build/test-results/acceptance-junit.xml', allowEmpty: true)
}

publishHTML (target : [
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'build/test-results',
reportFiles: '**/*.html',
reportName: 'Cypress Reports'
])

sh 'npm run generate:pdf'
zip zipFile: 'cypress/pdf.zip', archive: false, dir: 'build/test-results/mochawesome/pdf'
archiveArtifacts artifacts: 'cypress/pdf.zip', fingerprint: true, daysToKeep: 2, numToKeep: 3
archiveArtifacts artifacts: 'cypress/pdf.zip', fingerprint: true

if (fileExists('cypress/videos')) {
zip zipFile: 'cypress/videos.zip', archive: false, dir: 'cypress/videos'
}

if (fileExists('build/test-results/screenshots')) {
zip zipFile: 'cypress/screenshots.zip', archive: false, dir: 'build/test-results/screenshots'
archiveArtifacts artifacts: 'cypress/screenshots.zip', fingerprint: true, daysToKeep: 2, numToKeep: 3
}

if (status != 0) {
Expand Down
25 changes: 5 additions & 20 deletions e2e-cypress/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,23 @@ Please note that each stage is executed with its own Cypress configuration file

## Running end-to-end tests

Run `npm run e2e` to execute all end-to-end tests via [Cypress](https://www.cypress.io) against the test instance of the front end.
Run `npm run e2e` to execute all end-to-end tests via [Cypress](https://www.cypress.io) against the test instance of the front end. In order to run the tests against different environments for releases, you can define the base URLs of each environment in a config map in OpenShift, and import them as environment variables in the `Jenkinsfile`. See an example on how to do this using `context.environment` in the `Jenkinsfile`.

## Local development

Run `npm start` to develop the e2e tests. The tests will automatically rebuild and run, if you change any of the source files. Ideally the test will run against a local instance of the front end, e.g. `http://localhost:4200` for an Angular app. This destination is configurable in the `cypress.config.ts` file.

## How to upload images or videos to Nexus

Screenshots are only taken when test fails.
1. Open the Jenkinsfile
2. Replace `stageTest(context)` by the following lines:
```
def status = stageTest(context)
if (status != 0) {
odsComponentStageUploadToNexus(context,
[
distributionFile: 'tests/screenshots.zip',
repository: 'leva-documentation',
repositoryType: 'raw',
targetDirectory: "${targetDirectory}"])
}
```

## Reports
From [Merging reports across spec files](https://docs.cypress.io/guides/tooling/reporters#Merging-reports-across-spec-files): each spec file is processed completely separately during each cypress run execution. Thus each spec run overwrites the previous report file. To preserve unique reports for each spec file, use the `[hash]` in the `mochaFile` filename.

In order to generate one xml report per test type (installation, integration and acceptance) we use the junit-report-merger tool. See also the `junit-...-report` tasks in `package.json`.

## E2e test user authentication

With Cypress 12 version is now available `cy.origin()` that allows you to handle redirections. This funcionality eases the login handling.
See `./support/e2e.ts` for a generic login example.
With Cypress 12 version is now available `cy.origin()` that allows you to handle redirections. This functionality eases the login handling.
See `./support/login-functions.ts` for a generic login example.

In order to load your testing user's credentials for this login with SSO, you need to create a secret in OpenShift with the label `credential.sync.jenkins.openshift.io=true` and import them as environment variables using the withCredentials block to keep them secure. Find an example on how to do this in the `Jenkinsfile`.

## Cypress Cloud

Expand Down
2 changes: 1 addition & 1 deletion e2e-cypress/files/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineConfig({
viewportWidth: 1280,
viewportHeight: 720,
experimentalModifyObstructiveThirdPartyCode: true,
video: true,
video: false,
async setupNodeEvents(on, config) {
return (await import('./plugins/index')).default(on, config);
},
Expand Down

0 comments on commit c3d8976

Please sign in to comment.