Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(testing): support cypress reporterOptions as objects #17149

Merged
merged 1 commit into from
May 25, 2023

Conversation

barbados-clemens
Copy link
Contributor

@barbados-clemens barbados-clemens commented May 22, 2023

Current Behavior

cypress only accepts strings as reporter options but the cypress node api is marked as 'any'

Expected Behavior

pass any object as reporter options to cypress

Related Issue(s)

Terminal output from testing

❯ bat apps/demo-e2e/project.json
───────┬─────────────────────────────────────────────────────────────────────────────────────────────
       │ File: apps/demo-e2e/project.json
───────┼─────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │   "name": "demo-e2e",
   3   │   "$schema": "../../node_modules/nx/schemas/project-schema.json",
   4   │   "sourceRoot": "apps/demo-e2e/src",
   5   │   "projectType": "application",
   6   │   "targets": {
   7   │     "e2e": {
   8   │       "executor": "@nx/cypress:cypress",
   9   │       "options": {
  10   │         "cypressConfig": "apps/demo-e2e/cypress.config.ts",
  11   │         "devServerTarget": "demo:serve:development",
  12 ~"testingType": "e2e",
  13 ~"reporter": "junit",
  14 ~"reporterOptions": {
  15 ~"mochaFile": "../../dist/cypress/apps/demo-e2e/test-results.[hash].xml",
  16 ~"toConsole": true,
  17 ~"attachments": true
  18 ~ │         }
  19   │       },
  20   │       "configurations": {
  21   │         "production": {
  22   │           "devServerTarget": "demo:serve:production"
  23   │         },
  24   │         "ci": {
  25   │           "devServerTarget": "demo:serve-static"
  26   │         }
  27   │       }
  28   │     },
  29   │     "lint": {
  30   │       "executor": "@nx/linter:eslint",
  31   │       "outputs": ["{options.outputFile}"],
  32   │       "options": {
  33   │         "lintFilePatterns": ["apps/demo-e2e/**/*.{js,ts}"]
  34   │       }
  35   │     }
  36   │   },
  37   │   "tags": [],
  38   │   "implicitDependencies": ["demo"]
  39   │ }
───────┴─────────────────────────────────────────────────────────────────────────────────────────────
❯ nx e2e demo-e2e --skip-nx-cache

> nx run demo-e2e:e2e

  ➜  Local:   http://localhost:4200/
{
  mochaFile: '../../dist/cypress/apps/demo-e2e/test-results.[hash].xml',
  toConsole: true,
  attachments: true
}
DevTools listening on ws://127.0.0.1:50011/devtools/browser/d7e5e34b-fbbf-4976-b579-1fda81128747
Couldn't determine Mocha version
====================================================================================================
  (Run Starting)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        12.12.0                                                                        │
  │ Browser:        Electron 106 (headless)                                                        │
  │ Node Version:   v18.12.1 (/Users/caleb/.nvm/versions/node/v18.12.1/bin/node)                   │
  │ Specs:          1 found (app.cy.ts)                                                            │
  │ Searched:       src/**/*.cy.{js,jsx,ts,tsx}                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  app.cy.ts                                                                       (1 of 1)
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.247" tests="1" failures="0">
  <testsuite name="Root Suite" timestamp="2023-05-22T19:41:20" tests="0" file="src/e2e/app.cy.ts" time="0.000" failures="0">
  </testsuite>
  <testsuite name="demo" timestamp="2023-05-22T19:41:20" tests="1" time="0.231" failures="0">
    <testcase name="demo should display welcome message" time="0.232" classname="should display welcome message">
    </testcase>
  </testsuite>
</testsuites>
  (Results)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     app.cy.ts                                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
  (Video)
  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: 0 seconds
  -  Video output: /Users/caleb/Work/sandbox/cy-report-options/dist/cypress/apps/demo-e2e/videos/app.cy.ts.mp4
====================================================================================================
  (Run Finished)
       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  app.cy.ts                                245ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        245ms        1        1        -        -        -

 ———————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target e2e for project demo-e2e (4s)

❯ tree dist
dist
└── cypress
    └── apps
        └── demo-e2e
            ├── test-results.05b57a3a69ddd45da0cac5fc2fa9f6e7.xml
            └── videos
                └── app.cy.ts.mp4

4 directories, 2 files

Fixes #17024

@vercel
Copy link

vercel bot commented May 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2023 7:06pm

@barbados-clemens barbados-clemens self-assigned this May 22, 2023
@barbados-clemens barbados-clemens added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label May 22, 2023
@barbados-clemens barbados-clemens force-pushed the feat/cypress-reporter-opts branch from 9634ddf to 50f685c Compare May 24, 2023 18:58
@barbados-clemens barbados-clemens marked this pull request as ready for review May 24, 2023 20:12
@barbados-clemens barbados-clemens enabled auto-merge (squash) May 24, 2023 20:41
@AgentEnder AgentEnder disabled auto-merge May 25, 2023 15:37
@AgentEnder AgentEnder merged commit 26313f1 into nrwl:master May 25, 2023
@barbados-clemens barbados-clemens deleted the feat/cypress-reporter-opts branch May 25, 2023 16:11
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cypress executor's reporterOptions doesn't accept object.
2 participants