This duplicates the report in #634 (comment) and adds steps to reproduce.
Problem description
When the wait-on parameter of cypress-io/github-action is used to wait for the availability of an Angular server in a Node.js 18 environment on a GitHub ubuntu-22.04 runner, the wait times out and the following is shown in the logs:
Error: connect ECONNREFUSED 127.0.0.1:4200
This is a regression from Node.js 16.
Steps to reproduce
Create app
Follow the steps in Angular: Setting up the local environment and workspace to create a standard Angular 15 project.
Execute:
npm install -g @angular/cli
ng new angular-test
Accept defaults.
Set up Cypress
cd angular-test
npm install cypress@latest -D
npx cypress open
Select E2E Testing > Continue > Chrome > Start E2E Testing in Chrome
Create new spec > Create spec > Okay, run the spec
Edit
cypress/e2e/spec.cy.ts and replace https://example.cypress.io by http://localhost:4200/ so that the test spec line reads:
cy.visit('http://localhost:4200')
Execute:
The following is shown:
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
In a separate terminal window execute:
and confirm that the Cypress test completes successfully.
Add GitHub workflow
Create the file .github/workflows/cypress-test.yml with the following content:
name: cypress-test
on:
workflow_dispatch:
jobs:
start:
runs-on: ubuntu-22.04
strategy:
matrix:
node: [16, 18]
name: Angular E2E test on Node.js ${{ matrix.node }}
steps:
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Checkout
uses: actions/checkout@v3
- name: Cypress tests
uses: cypress-io/github-action@v5
with:
start: npm start
wait-on: 'http://localhost:4200'
browser: chrome
Run on GitHub
Commit the above to a GitHub repository and run .github/workflows/cypress-test.yml.
Note that the job runs successfully under Node.js 16 and fails under Node.js 18
Under Node.js 18 the following is seen in the log file:
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
✔ Compiled successfully.
http://localhost:4200 timed out on retry 91 of 3, elapsed 90286ms, limit 90000ms
Error: connect ECONNREFUSED 127.0.0.1:4200
Expected behavior
wait-on should correctly wait for an Angular server (ng serve) on Node.js 18 to allow Cypress testing to proceed when the server is available.
Workarounds
Use npm wait-on package
Use the npm package wait-on to wait for the Angular server ng serve to come online.
Execute:
and replace
wait-on: 'http://localhost:4200'
with a 60 second wait for the server using wait-on
wait-on: 'npx wait-on --timeout 60000 http://localhost:4200'
See README: Wait-on.
Use alternate server
Add an alternate http server to the configuration to replace ng serve. (npm install your-favorite-http-server and add start-alternate script to package.json)
npm run build causes ng build to be executed
npm run start-alternate starts the alternate http-server
- name: Cypress tests
uses: cypress-io/github-action@v5
with:
build: npm run build
start: npm run start-alternate
wait-on: 'http://localhost:4200'
browser: chrome
serve is an example of an http server which works in the above test for both Node.js 16 and Node.js 18.
IPv6 localhost address
Replace http://localhost:4200 by http://ip6-localhost:4200 in wait-on under Node.js 18
See also #634 (comment) from @mraible.
This duplicates the report in #634 (comment) and adds steps to reproduce.
Problem description
When the
wait-onparameter of cypress-io/github-action is used to wait for the availability of an Angular server in a Node.js 18 environment on a GitHub ubuntu-22.04 runner, the wait times out and the following is shown in the logs:This is a regression from Node.js 16.
Steps to reproduce
Create app
Follow the steps in Angular: Setting up the local environment and workspace to create a standard Angular 15 project.
Execute:
Accept defaults.
Set up Cypress
cd angular-test npm install cypress@latest -D npx cypress openSelect E2E Testing > Continue > Chrome > Start E2E Testing in Chrome
Create new spec > Create spec > Okay, run the spec
Edit
cypress/e2e/spec.cy.tsand replacehttps://example.cypress.iobyhttp://localhost:4200/so that the test spec line reads:Execute:
The following is shown:
In a separate terminal window execute:
and confirm that the Cypress test completes successfully.
Add GitHub workflow
Create the file
.github/workflows/cypress-test.ymlwith the following content:Run on GitHub
Commit the above to a GitHub repository and run
.github/workflows/cypress-test.yml.Note that the job runs successfully under Node.js 16 and fails under Node.js 18
Under Node.js 18 the following is seen in the log file:
Expected behavior
wait-on should correctly wait for an Angular server (
ng serve) on Node.js 18 to allow Cypress testing to proceed when the server is available.Workarounds
Use npm
wait-onpackageUse the npm package wait-on to wait for the Angular server
ng serveto come online.Execute:
and replace
with a 60 second wait for the server using wait-on
See README: Wait-on.
Use alternate server
Add an alternate http server to the configuration to replace
ng serve. (npm install your-favorite-http-serverand addstart-alternatescript topackage.json)npm run buildcausesng buildto be executednpm run start-alternatestarts the alternate http-serverserve is an example of an http server which works in the above test for both Node.js 16 and Node.js 18.
IPv6 localhost address
Replace
http://localhost:4200byhttp://ip6-localhost:4200inwait-onunder Node.js 18See also #634 (comment) from @mraible.