From f2e5c63d75fa3bd788b3e4bb754c7fc3e29889cd Mon Sep 17 00:00:00 2001
From: Pierre Smeyers <pierre.smeyers@gmail.com>
Date: Fri, 2 Sep 2022 17:59:48 +0200
Subject: [PATCH] feat: normalize reports

---
 README.md                       | 8 ++++----
 templates/gitlab-ci-cypress.yml | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 9861add..ec38581 100644
--- a/README.md
+++ b/README.md
@@ -31,11 +31,11 @@ It uses the following variable:
 | `CYPRESS_EXTRA_ARGS`  | Cypress extra [run options](https://docs.cypress.io/guides/guides/command-line.html#cypress-run) (to select a different browser, configuration or spec files for e.g.) | _none_ |
 | `REVIEW_ENABLED`      | Set to `true` to enable Cypress tests on review environments (dynamic environments instantiated on development branches) | _none_ (disabled) |
 
-### Unit tests report integration
+In addition to a textual report in the console, this job produces the following reports, kept for one day:
 
-Cypress test reports are [integrated to GitLab by generating JUnit reports](https://docs.gitlab.com/ee/ci/junit_test_reports.html).
-
-This is done using the following Cypress CLI options: `--reporter junit --reporter-options "mochaFile=cypress/reports/TEST-[hash].xml"`  
+| Report         | Format                                                                       | Usage             |
+| -------------- | ---------------------------------------------------------------------------- | ----------------- |
+| `$CYPRESS_PROJECT_DIR/reports/cypress-*.xunit.xml` | [xUnit](https://github.com/jest-community/jest-junit#readme) test report(s) | [GitLab integration](https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportsjunit) |
 
 ### Cypress `baseUrl` auto evaluation
 
diff --git a/templates/gitlab-ci-cypress.yml b/templates/gitlab-ci-cypress.yml
index 0e62e27..664ff38 100644
--- a/templates/gitlab-ci-cypress.yml
+++ b/templates/gitlab-ci-cypress.yml
@@ -243,17 +243,17 @@ cypress:
     # maybe activate DEBUG traces
     - 'if [[ "$TRACE" ]]; then export DEBUG=cypress:*; fi'
     # run Cypress tests
-    - cypress run --reporter junit --reporter-options "mochaFile=cypress/reports/TEST-[hash].xml" $CYPRESS_EXTRA_ARGS
+    - cypress run --reporter junit --reporter-options "mochaFile=reports/cypress-[hash].xunit.xml" $CYPRESS_EXTRA_ARGS
   artifacts:
     name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
     when: always
     paths:
-      - $CYPRESS_PROJECT_DIR/cypress/reports/
+      - "$CYPRESS_PROJECT_DIR/reports/cypress-*"
       - $CYPRESS_PROJECT_DIR/cypress/videos/
       - $CYPRESS_PROJECT_DIR/cypress/screenshots/
     reports:
       junit:
-        - $CYPRESS_PROJECT_DIR/cypress/reports/TEST-*.xml
+        - "$CYPRESS_PROJECT_DIR/reports/cypress-*.xunit.xml"
     expire_in: 1 day
   rules:
     - !reference [.acceptance-policy, rules]
-- 
GitLab