aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
449 stars 113 forks source link

"View Cypress Results" button leads to 404 #2341

Open adi518 opened 2 years ago

adi518 commented 2 years ago

Before opening, please confirm:

App Id

dazj4he0xk1lv

Region

us-east-1

Amplify Console feature

Previews

Describe the bug

Can't download Cypress tests results.

Expected behavior

Can download Cypress tests results.

Reproduction steps

Deploy with Cypress tests

Build Settings

# https://docs.amplify.aws/cli/usage/headless
# https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html
# https://github.com/aws-amplify/amplify-console/issues/176
# https://github.com/aws-amplify/amplify-console/issues/229
# https://github.com/aws-amplify/amplify-console/issues/1642
# https://github.com/aws-amplify/amplify-console/issues/1330#issuecomment-739493860
version: 1
backend:
  phases:
    preBuild:
      commands:
        - yum update --assumeyes
        # https://stedolan.github.io/jq/download/
        - wget --output-document jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
        - chmod +x ./jq
        - cp jq /usr/bin
        - echo "JQ_VERSION="$(jq --version)
        - node ./scripts/update_amplify_config.js
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - chmod u+x ./scripts/amplifyPush.sh
        - ./scripts/amplifyPush.sh --simple
frontend:
  phases:
    preBuild:
      commands:
        - nvm install 14
        - nvm use 14
        # https://stackoverflow.com/questions/58482655/what-is-the-closest-to-npm-ci-in-yarn
        - rm -rf node_modules && yarn install --frozen-lockfile # equivalent of `npm ci`
    build:
      commands:
        - yarn build

  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - ~/.cache
test:
  phases:
    preTest:
      commands:
        # https://docs.aws.amazon.com/amplify/latest/userguide/running-tests.html
        # https://aws.amazon.com/blogs/mobile/run-end-to-end-cypress-tests-for-your-fullstack-ci-cd-deployment-with-amplify-console/
        # https://github.com/aws-amplify/amplify-console/issues/583
        # https://github.com/aws-amplify/amplify-console/issues/240
        # https://github.com/cypress-io/cypress/issues/6960
        - nvm use 14
        - yarn add ts-node
        - yarn add wait-on
        - yarn add pm2
        - yarn add mocha mochawesome mochawesome-merge mochawesome-report-generator
        - yarn pm2 start 'yarn start:test'
        - yarn wait-on http://localhost:3000
    test:
      commands:
        # https://docs.cypress.io/guides/guides/command-line#cypress-run-config-lt-config-gt
        - yarn test:e2e:ci
    postTest:
      commands:
        - yarn mochawesome-merge cypress/report/mochawesome-report/*.json > cypress/report/mochawesome.json
        - yarn pm2 kill
  artifacts:
    baseDirectory: cypress
    configFilePath: '**/mochawesome.json'
    files:
      - '**/*.png'
      - '**/*.mp4'

Additional information

I'm also not seeing a "pretty" display of the tests, it's just the log, which makes it very hard to figure out what happened when tests fail. I checked #176, but it doesn't fix it.

ambreen-ilyas commented 2 years ago

Hey, I was getting the same problem with the 404... the two changes that worked for me: The artifacts: ConfigFilePath and the artifacts: files. I think you need:

configFilePath: report/mochawesome.json files: - "**/*.html"

Hope that helps πŸ˜„

adi518 commented 2 years ago

I'll give it a shot and if it fixes it, the docs MUST be fixed ASAP. πŸ‘Ž

ambreen-ilyas commented 2 years ago

Its weird, I was stuck on this a little while but nowhere in the docs could I find this highlighted.. it seems obvious now that I know!

adi518 commented 2 years ago

Still not working. I'm tired of this guessing game.

swaminator commented 2 years ago

@adi518 we will be addressing this as priority.

ghost commented 2 years ago

Hi @adi518 πŸ‘‹πŸ½, can you provide reproduction steps or a demo repository that reproduces this 404 behavior?

adi518 commented 2 years ago

@hloriana Just check out my app from the app id above. You can run a preview build and debug from there.

glazovg commented 2 years ago

Having same issue, does anyone figure out how to fix it? 😞 CC @hloriana

adi518 commented 2 years ago

No fix and it's probably stupid easy to fix, yet they don't prioritize it.

joekiller commented 2 years ago

It's unclear how the cypress.config of the application being tested experiencing the 404 is configured given the original information. It could be that the config is missing the reporter options that typically in the examples is supplied by external arguments. That may explain "why it's not working" because it would be reasonable to assume the report files are not being generated.

In the Add tests to your existing Amplify app example the reporter options are explicitly added via:

'npx cypress run --reporter mochawesome --reporter-options "reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss"'

Perhaps try replacing yarn test:e2e:ci with the above or ensure your cypress config is setup to write the reports as expected.

cwaldvonderlahr commented 1 year ago

Anything new on the topic?