aws-amplify / aws-amplify/amplify-hosting

E2E Cypress tests not running - Build succeeds

Open
#3,765 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting questions](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have removed any sensitive information from my code snippets and submission.

### App Id

d21fhrz7phtggn

### AWS Region

eu-north-1

### Amplify Hosting feature

E2E Cypress tests

### Question

I have been following the official docs https://docs.aws.amazon.com/amplify/latest/userguide/running-tests.html for running Cypress tests within AWS Amplify, but I am running into an issue with the test stage.
Currently my testing step gets through to my 'test' phase, then throws an error.

I am not too sure if I have gone wrong somewhere in my `amplify.yml` file or in the project itself.
Cypress E2E runs fine locally, and all test are currently passing.

Build settings:
```
version: 1
frontend:
phases:
preBuild:
commands:
- cd astro
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: ./astro/dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
test:
artifacts:
baseDirectory: ./astro/cypress
files:
- '**/*.png'
- '**/*.mp4'
phases:
preTest:
commands:
- cd astro
- npm ci
- npm install -g pm2
- npm install -g wait-on
- npm install mocha mochawesome mochawesome-merge mochawesome-report-generator
- pm2 start npm -- start
- wait-on http://localhost:4321
test:
commands:
- npx run cypress run --reporter mochawesome --reporter-options 'reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss'
postTest:
commands:
- npx run mochawesome-merge cypress/report/mochawesome-report/*.json > cypress/report/mochawesome.json
- npx pm2 kill
```

Test logs:
```
# Starting phase: preTest
# Executing command: cd astro
2023-10-20T07:56:30.123Z [INFO]: # Executing command: npm ci
2023-10-20T07:56:40.895Z [INFO]: added 854 packages, and audited 855 packages in 11s
2023-10-20T07:56:40.898Z [INFO]: 261 packages are looking for funding
run `npm fund` for details
2023-10-20T07:56:40.916Z [INFO]: 8 vulnerabilities (6 low, 1 moderate, 1 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
2023-10-20T07:56:40.944Z [INFO]: # Executing command: npm install -g pm2
2023-10-20T07:56:46.319Z [WARNING]: npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
2023-10-20T07:56:46.890Z [INFO]: added 156 packages in 6s
2023-10-20T07:56:46.891Z [INFO]: 12 packages are looking for funding
run `npm fund` for details
2023-10-20T07:56:46.901Z [INFO]: # Executing command: npm install -g wait-on
2023-10-20T07:56:48.291Z [INFO]: added 19 packages in 1s
2023-10-20T07:56:48.291Z [INFO]: 2 packages are looking for funding
run `npm fund` for details
2023-10-20T07:56:48.299Z [INFO]: # Executing command: npm install mocha mochawesome mochawesome-merge mochawesome-report-generator
2023-10-20T07:56:51.448Z [INFO]: added 101 packages, and audited 956 packages in 3s
2023-10-20T07:56:51.450Z [INFO]: 266 packages are looking for funding
run `npm fund` for details
2023-10-20T07:56:51.468Z [INFO]: 8 vulnerabilities (6 low, 1 moderate, 1 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
2023-10-20T07:56:51.478Z [INFO]: # Executing command: pm2 start npm -- start
2023-10-20T07:56:51.640Z [INFO]: -------------
__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
_\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
_\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
_\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
_\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
_\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
_\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
_\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
_\///______________\///______________\///__\///////////////__
Runtime Edition
PM2 is a Production Process Manager for Node.js applications
with a built-in Load Balancer.
Start and Daemonize any application:
$ pm2 start app.js
Load Balance 4 instances of api.js:
$ pm2 start api.js -i 4
Monitor in production:
$ pm2 monitor
Make pm2 auto-boot at server restart:
$ pm2 startup
To go further checkout:
http://pm2.io/
-------------
2023-10-20T07:56:51.746Z [INFO]: [PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
2023-10-20T07:56:51.898Z [INFO]: [PM2] PM2 Successfully daemonized
2023-10-20T07:56:51.912Z [INFO]: [PM2] Starting /usr/local/bin/npm in fork_mode (1 instance)
2023-10-20T07:56:51.925Z [INFO]: [PM2] Done.
2023-10-20T07:56:51.941Z [INFO]: ┌────┬────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├────┼────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ npm │ default │ N/A │ fork │ 535 │ 0s │ 0 │ online │ 0% │ 35.7mb │ root │ disabled │
└────┴────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
2023-10-20T07:56:51.948Z [INFO]: # Executing command: wait-on http://localhost:4321
2023-10-20T07:56:54.920Z [INFO]: # Completed phase: preTest
# Starting phase: test
2023-10-20T07:56:54.926Z [INFO]: # Executing command: npx run cypress run --reporter mochawesome --reporter-options 'reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss'
2023-10-20T07:56:56.113Z [WARNING]: npm
2023-10-20T07:56:56.114Z [WARNING]: WARN exec The following package was not found and will be installed: run@1.4.0
2023-10-20T07:56:56.384Z [INFO]: Watching /codebuild/output/src3790170128/src/afenwick-astro/astro and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
2023-10-20T07:56:56.386Z [WARNING]: /root/.npm/_npx/755986f37193a6d8/node_modules/run/run.js:127
if (minimatch(file, pattern)) {
^
TypeError: minimatch is not a function
at /root/.npm/_npx/755986f37193a6d8/node_modules/run/run.js:127:13
at Array.forEach ()
at parseFolder (/root/.npm/_npx/755986f37193a6d8/node_modules/run/run.js:113:9)
at Object. (/root/.npm/_npx/755986f37193a6d8/node_modules/run/run.js:63:12)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
Node.js v18.18.0
2023-10-20T07:56:56.398Z [INFO]: # Completed phase: test
# Starting phase: postTest
2023-10-20T07:56:56.398Z [INFO]: # Executing command: npx run mochawesome-merge cypress/report/mochawesome-report/*.json > cypress/report/mochawesome.json
2023-10-20T07:56:56.398Z [WARNING]: /codebuild/output/src3790170128/src/afenwick-astro/tests.sh: line 34: cypress/report/mochawesome.json: No such file or directory
2023-10-20T07:56:56.398Z [ERROR]: !!! Test execution failed, one or more tests are not passing
2023-10-20T07:56:56.399Z [INFO]: # Starting test artifact upload process...
2023-10-20T07:56:56.414Z [INFO]: # Uploading build artifact 'testArtifacts.zip'...
2023-10-20T07:56:56.543Z [INFO]: # Test artifact upload completed
2023-10-20T07:56:56.543Z [ERROR]: !!! Non-Zero Exit Code detected
2023-10-20T07:56:56.543Z [INFO]: # Starting environment caching...
2023-10-20T07:56:56.544Z [INFO]: # Uploading environment cache artifact...
2023-10-20T07:56:56.611Z [INFO]: # Uploaded environment cache artifact
2023-10-20T07:56:56.612Z [INFO]: # Environment caching completed
Terminating logging...
```

Contributor guide

Open the contributing guide

Research direction

Start with the running-tests documentation and the reported amplify.yml configuration. Reproduce the test phase using the logged `npx run cypress run` command, then inspect the postTest command and its missing report path. Done means the Cypress command executes without the shown runner error and test artifacts are generated successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cypress, node.js
Domain
ci-cd, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.