nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.17k stars 2.3k forks source link

Cypress e2e test not able to run in azure devops CI pipeline #27097

Closed sshelake25 closed 2 weeks ago

sshelake25 commented 1 month ago

Current Behavior

Can we update steps in current CI setup how to run cypress for angular e2e project in azure devosp https://nx.dev/ci/recipes/set-up/monorepo-ci-azure

NX Running target e2e-ci for project hello-e2e and 1 task it depends on failed

nx run hello-e2e:e2e-ci--src/e2e/app.cy.ts 2024-07-24T17:02:05.8346163Z 2024-07-24T17:02:06.4037838Z It looks like this is your first time using Cypress: 13.10.0 2024-07-24T17:02:06.4038466Z 2024-07-24T17:02:06.4076369Z [STARTED] Task without title. 2024-07-24T17:02:08.1896230Z [SUCCESS] Task without title. 2024-07-24T17:02:08.1896776Z 2024-07-24T17:02:08.1897143Z Opening Cypress... 2024-07-24T17:02:08.4247829Z 2024-07-24T17:02:09.7781853Z 2024-07-24T17:02:09.7789432Z DevTools listening on ws://127.0.0.1:50851/devtools/browser/f81fc2fa-7bae-4e08-adf1-15c29544ed4a 2024-07-24T17:02:12.7155936Z spawn EINVAL 2024-07-24T17:03:12.4662843Z Your configFile threw an error from: D:\a\1\s\apps\hello-e2e\cypress.config.ts 2024-07-24T17:03:12.4667681Z  2024-07-24T17:03:12.4670778Z The error was thrown while executing your e2e.setupNodeEvents() function: 2024-07-24T17:03:12.4680846Z  2024-07-24T17:03:12.4688911Z Error: Web server failed to start in 60000ms. This can be configured in cypress.config.ts. 2024-07-24T17:03:12.4698390Z  at Timeout._onTimeout (D:\a\1\s\node_modules\@nx\cypress\plugins\cypress-preset.js:124:20) 2024-07-24T17:03:12.4702489Z  at listOnTimeout (node:internal/timers:569:17) 2024-07-24T17:03:12.4703418Z  at processTimers (node:internal/timers:512:7) 2024-07-24T17:03:12.5485111Z Warning: command "cypress run --env webServerCommand="npx nx run hello:serve-static --verbose" --spec src/e2e/app.cy.ts" exited with non-zero status code 2024-07-24T17:03:12.5487840Z 2024-07-24T17:03:12.5489992Z 2024-07-24T17:03:12.5490764Z NX Running target e2e-ci for project hello-e2e and 1 task it depends on failed 2024-07-24T17:03:12.5491094Z 2024-07-24T17:03:12.5491366Z Failed tasks: 2024-07-24T17:03:12.5491538Z 2024-07-24T17:03:12.5491812Z - hello-e2e:e2e-ci--src/e2e/app.cy.ts 2024-07-24T17:03:12.5491986Z

Expected Behavior

should able to run cypress test as part of azure devops CI pipeline

GitHub Repo

No response

Steps to Reproduce

1. create angular nx project with end to end project setp simple devops pipeline to cypress end to end test in cli in local enviroment e2e ci commnad working find

Nx Report

==================================================================================================

  (Run Finished)

       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  app.cy.ts                                760ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        760ms        1        1        -        -        -  

> nx run hello-e2e:e2e-ci

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

 NX   Successfully ran target e2e-ci for project hello-e2e and 1 task it depends on (1m)

Merit@RAC074 MINGW64 /d/who/Omni (task/86859-cypress-ci)
$ nx report

 >  NX   Its time to update Nx 🎉

   Your repository uses a higher version of Nx (17.0.5) than your global CLI version (16.8.1)
   For more information, see https://nx.dev/more-concepts/global-nx

 NX   Report complete - copy this into the issue template

Node   : 20.9.0
OS     : win32-x64
npm    : 10.1.0

nx (global)        : 16.8.1
nx                 : 17.0.5
@nx/js             : 17.0.5
@nx/jest           : 16.10.0
@nx/linter         : 17.0.5
@nx/eslint         : 17.0.5
@nx/workspace      : 17.0.5
@nx/angular        : 17.0.5
@nx/cypress        : 17.0.5
@nx/devkit         : 17.0.2
@nx/eslint-plugin  : 17.0.5
@nrwl/tao          : 17.0.5
@nx/web            : 17.0.5
@nx/webpack        : 17.0.5
typescript         : 5.4.2
---------------------------------------
Registered Plugins:
@nx-dotnet/core
@nx/cypress/plugin
@nx/eslint/plugin
---------------------------------------
Community plugins:
@ngrx/effects          : 17.2.0
@ngrx/schematics       : 17.2.0
@ngrx/store            : 17.2.0
@ngrx/store-devtools   : 17.2.0
@ngx-formly/schematics : 6.3.0
@nx-dotnet/core        : 2.2.0
angular-calendar       : 0.31.0
ng-mocks               : 14.12.2
ngx-mailto             : 17.0.0
ngx-toastr             : 16.1.1
---------------------------------------
The following packages should match the installed version of nx
  - @nx/jest@16.10.0
  - @nrwl/jest@16.10.0
  - @nx/devkit@17.0.2
  - @nrwl/devkit@17.0.2

To fix this, run `nx migrate nx@17.0.5`

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

locally running fine Building... polyfills-3ITNT4UF.js 34.3kb Done in 177ms main-VBHUS333.js 202.4kb Done in 16542ms Initial chunk files | Names | Raw size | Estimated transfer size main-VBHUS333.js | main | 202.44 kB | 53.81 kB polyfills-3ITNT4UF.js | polyfills | 34.28 kB | 11.14 kB styles-5INURTSO.css | styles | 0 bytes | 0 bytes

                  | Initial total | 236.72 kB |                64.95 kB

Output location: D:\who\Omni\dist\apps\hello

Application bundle generation complete. [18.839 seconds]

NX Successfully ran target build for project hello

Starting up http-server, serving dist/apps/hello/browser

http-server version: 14.1.1

http-server settings: CORS: true Cache: -1 seconds Connection Timeout: 120 seconds Directory Listings: visible AutoIndex: visible Serve GZIP Files: false Serve Brotli Files: false Default File Extension: none

Available on: http://localhost:4200 Unhandled requests will be served from: http://localhost:4200?. Options: {"secure":false,"prependPath":true} Hit CTRL-C to stop the server

(node:23636) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated (Use node --trace-deprecation ... to show where the warning was created)

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Cypress: 13.10.0 │ │ Browser: Electron 118 (headless) │ │ Node Version: v20.9.0 (C:\Program Files\nodejs\node.exe) │ │ Specs: 1 found (app.cy.ts) │ │ Searched: D:\who\Omni\apps\hello-e2e\src\e2e\app.cy.ts │ └────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

Running: app.cy.ts (1 of 1)

hello-e2e √ should display welcome message (682ms)

1 passing (762ms)

(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Tests: 1 │ │ Passing: 1 │ │ Failing: 0 │ │ Pending: 0 │ │ Skipped: 0 │ │ Screenshots: 0 │ │ Video: false │ │ Duration: 0 seconds │ │ Spec Ran: app.cy.ts │ └────────────────────────────────────────────────────────────────────────────────────────────────┘

====================================================================================================

(Run Finished)

   Spec                                              Tests  Passing  Failing  Pending  Skipped  

┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ ✔ app.cy.ts 760ms 1 1 - - - │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ ✔ All specs passed! 760ms 1 1 - - -

nx run hello-e2e:e2e-ci

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

NX Successfully ran target e2e-ci for project hello-e2e and 1 task it depends on (1m)

sshelake25 commented 1 month ago

failed_logs.txt

sshelake25 commented 1 month ago

Any help? I am really stuck to run e2e test on azure ci pipeline

FrozenPandaz commented 1 month ago

Hi, it seems like the command is timing out. Could you try to increase the timeout in your cypress.config.ts?

    ...nxE2EPreset(__dirname, {
      webServerCommands: {
        default: 'pnpm exec nx run graph-client:serve --configuration=dev-e2e',
      },
      webServerConfig: {
        timeout: 120000,
      },
    }),

How long does it take for you locally? Sometimes CI takes longer to run commands.

@leosvelperez Is the timeout documented? I couldn't find it here: https://nx.dev/nx-api/cypress#splitting-e2e-tasks-by-file

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because more information has not been provided within 7 days. It will be closed in 21 days if no information is provided. If information has been provided, please reply to keep it active. Thanks for being a part of the Nx community! 🙏