Commit 2ea7df78 authored by HERMI Aymen's avatar HERMI Aymen Committed by Pierre Smeyers
Browse files

feat: add custom reporters support

parent a48bc049
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ It uses the following variable:
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| `image` / `PLAYWRIGHT_IMAGE`                          | The Docker image used to run Playwright.                                                                                                                                                                                | `mcr.microsoft.com/playwright:latest`<br/>[![Trivy Badge](https://to-be-continuous.gitlab.io/doc/secu/trivy-badge-PLAYWRIGHT_IMAGE.svg)](https://to-be-continuous.gitlab.io/doc/secu/trivy-PLAYWRIGHT_IMAGE) |
| `project-dir` / `PLAYWRIGHT_PROJECT_DIR` | The Playwright root project directory (contains the `playwright.config.ts` file)                                            | `.`                                         |
| `extra-reporters` / `PLAYWRIGHT_EXTRA_REPORTERS`      | Playwright extra [reporters](https://playwright.dev/docs/test-reporters#built-in-reporters) (in addition to the JUnit reporter that is always generated). Comma separated list among `list`, `line`, `dot`, `json`, `html`. | *none*                                                                                                                                                                                                       |
| `extra-args` / `PLAYWRIGHT_EXTRA_ARGS` | Playwright extra [run options](https://playwright.dev/docs/test-cli)                                                        | _none_                                      |
| `review-enabled` / `REVIEW_ENABLED` | Set to `true` to enable Playwright tests on review environments (dynamic environments instantiated on development branches) | _none_ (disabled)                           |
| `node-install-extra-opts` / `NODE_INSTALL_EXTRA_OPTS` | Extra [`npm ci`](https://docs.npmjs.com/cli/ci.html/) options to install project dependencies | _none_ |
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,11 @@
      "description": "The Playwright root project directory (contains the `playwright.config.ts` file)",
      "default": "."
    },
    {
      "name": "PLAYWRIGHT_EXTRA_REPORTERS",
      "description": "Playwright extra [reporters](https://playwright.dev/docs/test-reporters#built-in-reporters) (in addition to the JUnit reporter that is always generated). Comma separated list among `list`, `line`, `dot`, `json`, `html`.",
      "type": "text"
    },
    {
      "name": "PLAYWRIGHT_EXTRA_ARGS",
      "description": "Playwright extra [run options](https://playwright.dev/docs/test-cli)",
+11 −1
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@ spec:
    project-dir:
      description: The Playwright root project directory (contains the `playwright.config.ts` file)
      default: .
    extra-reporters:
      description: Playwright extra [reporters](https://playwright.dev/docs/test-reporters#built-in-reporters) (in addition to the JUnit reporter that is always generated). Comma separated list among `list`, `line`, `dot`, `json`, `html`.
      default: ''
    extra-args:
      description: Playwright extra [run options](https://playwright.dev/docs/test-cli)
      default: ''
@@ -95,6 +98,7 @@ variables:

  NODE_INSTALL_EXTRA_OPTS: $[[ inputs.node-install-extra-opts ]]

  PLAYWRIGHT_EXTRA_REPORTERS: $[[ inputs.extra-reporters ]]
  PLAYWRIGHT_EXTRA_ARGS: $[[ inputs.extra-args ]]
  REVIEW_ENABLED: $[[ inputs.review-enabled ]]

@@ -393,6 +397,11 @@ playwright:
  variables:
    # NPM cache
    npm_config_cache: "$CI_PROJECT_DIR/$PLAYWRIGHT_PROJECT_DIR/.npm"
    # default Playwright reporter options
    PLAYWRIGHT_HTML_OUTPUT_DIR: "$CI_PROJECT_DIR/$PLAYWRIGHT_PROJECT_DIR/reports/playwright-html"
    PLAYWRIGHT_HTML_OPEN: "never"
    PLAYWRIGHT_JSON_OUTPUT_FILE: "$CI_PROJECT_DIR/$PLAYWRIGHT_PROJECT_DIR/reports/playwright.native.json"
    PLAYWRIGHT_JUNIT_OUTPUT_FILE: "$CI_PROJECT_DIR/$PLAYWRIGHT_PROJECT_DIR/reports/playwright.xunit.xml"
  cache:
    # cache per branch per template
    key: "$CI_COMMIT_REF_SLUG-playwright"
@@ -409,7 +418,7 @@ playwright:
    # maybe execute pre hook
    - maybe_exec_hook "./pre-playwright.sh"
    # run tests
    - PLAYWRIGHT_JUNIT_OUTPUT_NAME=reports/playwright.xunit.xml npx playwright test ${TRACE+--debug} --reporter=junit $PLAYWRIGHT_EXTRA_ARGS || rc=$?
    - npx playwright test ${TRACE+--debug} --reporter=junit${PLAYWRIGHT_EXTRA_REPORTERS:+,}${PLAYWRIGHT_EXTRA_REPORTERS} $PLAYWRIGHT_EXTRA_ARGS || rc=$?
    # maybe execute post hook
    - maybe_exec_hook "./post-playwright.sh"
    # exit with return code
@@ -419,6 +428,7 @@ playwright:
    when: always
    paths:
      - $PLAYWRIGHT_PROJECT_DIR/reports/playwright.*
      - $PLAYWRIGHT_PROJECT_DIR/reports/playwright-html/
    reports:
      # use JUnit format and GitLab integration (see: https://docs.gitlab.com/ci/yaml/#artifactsreports)
      junit: