Amplify-console: Cypress Test hangs indefinitely and will not deploy

Created on 12 Nov 2019  ·  17Comments  ·  Source: aws-amplify/amplify-console

Describe the bug
I have integrated Cypress into my app, followed all the instructions, made a Cypress dashboard account, added the env variable, added a cypress test to my app, ensured it passed, but no matter what I do, the Amplify build hangs on the Test tab.

This is a basic Create React App with AppSync and Apollo. I'm just trying to get the initial build stuff set up and I'm stuck.

                                 # Starting phase: preTest
                                 # Executing command: npm install
2019-11-12T08:59:07.953Z [WARNING]: npm
2019-11-12T08:59:07.956Z [WARNING]: WARN deprecated [email protected]: use String.prototype.padStart()
                                 # Starting phase: preTest
                                 # Executing command: npm install
2019-11-12T08:59:07.953Z [WARNING]: npm
2019-11-12T08:59:07.956Z [WARNING]: WARN deprecated [email protected]: use String.prototype.padStart()
2019-11-12T08:59:25.069Z [WARNING]: npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
2019-11-12T08:59:41.562Z [INFO]: > [email protected] preuninstall /codebuild/output/src244406029/src/app/node_modules/husky
                                 > node husky uninstall
2019-11-12T08:59:41.675Z [INFO]: husky > Uninstalling git hooks
2019-11-12T08:59:41.682Z [INFO]: husky > Done
2019-11-12T08:59:41.722Z [WARNING]: npm
2019-11-12T08:59:41.723Z [WARNING]: WARN rm not removing /codebuild/output/src244406029/src/app/node_modules/.bin/jest as it wasn't installed by /codebuild/output/src244406029/src/app/node_modules/jest
2019-11-12T08:59:41.746Z [WARNING]: npm
2019-11-12T08:59:41.747Z [WARNING]: WARN rm not removing /codebuild/output/src244406029/src/app/node_modules/.bin/rimraf as it wasn't installed by /codebuild/output/src244406029/src/app/node_modules/rimraf
2019-11-12T08:59:41.811Z [WARNING]: npm
2019-11-12T08:59:41.812Z [WARNING]: WARN rm not removing /codebuild/output/src244406029/src/app/node_modules/.bin/uglifyjs as it wasn't installed by /codebuild/output/src244406029/src/app/node_modules/uglify-js
2019-11-12T08:59:41.889Z [WARNING]: npm
2019-11-12T08:59:41.889Z [WARNING]: WARN rm not removing /codebuild/output/src244406029/src/app/node_modules/.bin/semver as it wasn't installed by /codebuild/output/src244406029/src/app/node_modules/semver
2019-11-12T08:59:42.032Z [WARNING]: npm WARN rm not removing /codebuild/output/src244406029/src/app/node_modules/.bin/is-ci as it wasn't installed by /codebuild/output/src244406029/src/app/node_modules/is-ci
2019-11-12T08:59:42.056Z [WARNING]: npm
2019-11-12T08:59:42.056Z [WARNING]: WARN rm not removing /codebuild/output/src244406029/src/app/node_modules/.bin/esparse as it wasn't installed by /codebuild/output/src244406029/src/app/node_modules/esprima
                                    npm WARN rm not removing /codebuild/output/src244406029/src/app/node_modules/.bin/esvalidate as it wasn't installed by /codebuild/output/src244406029/src/app/node_modules/esprima
2019-11-12T08:59:52.035Z [INFO]: > [email protected] install /codebuild/output/src244406029/src/app/node_modules/husky
                                 > node husky install
2019-11-12T08:59:52.158Z [INFO]: husky > Setting up git hooks
2019-11-12T08:59:52.167Z [INFO]: CI detected, skipping Git hooks installation.
2019-11-12T08:59:52.167Z [INFO]: husky > Done
2019-11-12T08:59:52.171Z [INFO]: > [email protected] install /codebuild/output/src244406029/src/app/node_modules/node-sass
                                 > node scripts/install.js
2019-11-12T08:59:52.440Z [INFO]: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.13.0/linux-x64-64_binding.node
2019-11-12T08:59:52.807Z [INFO]: Download complete
2019-11-12T08:59:52.810Z [INFO]: Binary saved to /codebuild/output/src244406029/src/app/node_modules/node-sass/vendor/linux-x64-64/binding.node
2019-11-12T08:59:52.839Z [INFO]: Caching binary to /root/.npm/node-sass/4.13.0/linux-x64-64_binding.node
2019-11-12T08:59:52.925Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/babel-runtime/node_modules/core-js
                                 > node postinstall || echo "ignore"
2019-11-12T08:59:53.090Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/react-app-polyfill/node_modules/core-js
                                 > node scripts/postinstall || echo "ignore"
2019-11-12T08:59:53.259Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/cypress
                                 > node index.js --exec install
2019-11-12T08:59:53.646Z [INFO]: Installing Cypress (version: 3.6.1)
2019-11-12T08:59:53.646Z [INFO]: 
2019-11-12T08:59:53.647Z [INFO]: [?25l
2019-11-12T08:59:53.650Z [INFO]: [08:59:53]  Downloading Cypress     [started]
2019-11-12T08:59:55.380Z [INFO]: [08:59:55]  Downloading Cypress     [completed]
2019-11-12T08:59:53.646Z [INFO]: Installing Cypress (version: 3.6.1)
2019-11-12T08:59:53.646Z [INFO]: 
2019-11-12T08:59:53.647Z [INFO]: [?25l
2019-11-12T08:59:53.650Z [INFO]: [08:59:53]  Downloading Cypress     [started]
2019-11-12T08:59:55.380Z [INFO]: [08:59:55]  Downloading Cypress     [completed]
2019-11-12T08:59:55.381Z [INFO]: [08:59:55]  Unzipping Cypress       [started]
2019-11-12T09:00:17.635Z [INFO]: [09:00:17]  Unzipping Cypress       [completed]
2019-11-12T09:00:17.636Z [INFO]: [09:00:17]  Finishing Installation  [started]
2019-11-12T09:00:17.654Z [INFO]: [09:00:17]  Finishing Installation  [completed]
2019-11-12T09:00:17.655Z [INFO]: [?25h
2019-11-12T09:00:18.655Z [INFO]: 
2019-11-12T09:00:18.656Z [INFO]: You can now open Cypress by running: node_modules/.bin/cypress open
                                 https://on.cypress.io/installing-cypress
                                 [?25h
2019-11-12T09:00:18.670Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/core-js
                                 > node postinstall || echo "ignore"
2019-11-12T09:00:18.736Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/husky
                                 > opencollective-postinstall || exit 0
2019-11-12T09:00:18.799Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/node-sass
                                 > node scripts/build.js
2019-11-12T09:00:18.942Z [INFO]: Binary found at /codebuild/output/src244406029/src/app/node_modules/node-sass/vendor/linux-x64-64/binding.node
2019-11-12T09:00:18.943Z [INFO]: Testing binary
2019-11-12T09:00:19.032Z [INFO]: Binary is fine
2019-11-12T09:00:20.133Z [WARNING]: npm
2019-11-12T09:00:20.134Z [WARNING]: notice created a lockfile as package-lock.json. You should commit this file.
                                    npm WARN [email protected] requires a peer of graphql@^0.11.0 but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
                                    npm WARN
2019-11-12T09:00:20.136Z [WARNING]: notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-11-12T09:00:20.137Z [INFO]: added 219 packages from 154 contributors, removed 479 packages, updated 1741 packages and audited 908803 packages in 105.249s
                                 found 0 vulnerabilities
2019-11-12T09:00:20.162Z [INFO]: # Executing command: npm install wait-on
2019-11-12T09:00:28.896Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/wait-on/node_modules/core-js
                                 > node postinstall || echo "ignore"
2019-11-12T09:00:28.896Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/wait-on/node_modules/core-js
                                 > node postinstall || echo "ignore"
2019-11-12T09:00:28.896Z [INFO]: > [email protected] postinstall /codebuild/output/src244406029/src/app/node_modules/wait-on/node_modules/core-js
                                 > node postinstall || echo "ignore"
2019-11-12T09:00:30.209Z [WARNING]: npm WARN [email protected] requires a peer of graphql@^0.11.0 but none is installed. You must install peer dependencies yourself.
2019-11-12T09:00:30.211Z [WARNING]: npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-11-12T09:00:30.212Z [INFO]: + [email protected]
                                 added 3 packages from 2 contributors and audited 908876 packages in 9.7s
                                 found 0 vulnerabilities
2019-11-12T09:00:30.222Z [INFO]: # Executing command: npm install  [email protected] mochawesome mochawesome-merge mochawesome-report-generator
2019-11-12T09:00:41.900Z [WARNING]: npm WARN [email protected] requires a peer of graphql@^0.11.0 but none is installed. You must install peer dependencies yourself.
2019-11-12T09:00:41.902Z [WARNING]: npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-11-12T09:00:41.903Z [INFO]: + [email protected]
                                 + [email protected]
                                 + [email protected]
                                 + [email protected]
                                 added 50 packages from 455 contributors and audited 909178 packages in 11.331s
                                 found 0 vulnerabilities
2019-11-12T09:00:41.915Z [INFO]: # Executing command: npm start & npx wait-on http://127.0.0.1:8080
2019-11-12T09:00:42.105Z [INFO]: > [email protected] start /codebuild/output/src244406029/src/app
                                 > react-scripts start
2019-11-12T09:00:43.343Z [INFO]: Starting the development server...
2019-11-12T09:00:41.903Z [INFO]: + [email protected]
                                 + [email protected]
                                 + [email protected]
                                 + [email protected]
                                 added 50 packages from 455 contributors and audited 909178 packages in 11.331s
                                 found 0 vulnerabilities
2019-11-12T09:00:41.915Z [INFO]: # Executing command: npm start & npx wait-on http://127.0.0.1:8080
2019-11-12T09:00:42.105Z [INFO]: > [email protected] start /codebuild/output/src244406029/src/app
                                 > react-scripts start
2019-11-12T09:00:43.343Z [INFO]: Starting the development server...
2019-11-12T09:00:41.903Z [INFO]: + [email protected]
                                 + [email protected]
                                 + [email protected]
                                 + [email protected]
                                 added 50 packages from 455 contributors and audited 909178 packages in 11.331s
                                 found 0 vulnerabilities
2019-11-12T09:00:41.915Z [INFO]: # Executing command: npm start & npx wait-on http://127.0.0.1:8080
2019-11-12T09:00:42.105Z [INFO]: > [email protected] start /codebuild/output/src244406029/src/app
                                 > react-scripts start
2019-11-12T09:00:43.343Z [INFO]: Starting the development server...
2019-11-12T09:00:57.442Z [INFO]: Compiled successfully!

After 30 minutes, it ultimately fails. When I download the artifacts, I see this:

<Error>
  <Code>NoSuchKey</Code>
  <Message>The specified key does not exist.</Message>
  <Key>rpcrmq0xq6e1or/develop/0000000026/TEST/artifacts/testArtifacts.zip</Key>
  <RequestId>{SOMEREQUESTID}</RequestId>
  <HostId>{SOMEHOSTID}</HostId>
</Error>

To Reproduce
As stated above.

Expected behavior
I expect it to run the cypress test as described in the documentation.

bug pending-customer-response

Most helpful comment

Thank you. I made a public repo that is essentially the same project (with the code that is specific to the amplify backend on my org’s AWS account removed).

https://github.com/stevensacks/amplify-test

All 17 comments

Here's what I've discovered after hours of messing around with it.

First off, I was using yarn for create react app. However, the docs for Cypress and Amplify use npm in the amplify.xml. So, I switched from yarn to npm for the project to see if that had an effect. It did. The test panel properly installed Cypress. I'm guessing there's some (undocumented?) changes to the cypress configuration you have to make when using yarn instead of npm.

HOWEVER, while the URL that the docs say to put into the amplify.yml as the "wait on" is http://127.0.0.1:8080, when Amplify runs the development server, the log says it's serving from http://172.17.0.2:3000. Is this an Amplify bug or does Cypress have the url wrong in their file? (or was the URL that Amplify runs the dev server at changed since Cypress wrote their docs?)

Since nothing ever launches on http://127.0.0.1:8080, it hangs indefinitely waiting on it. So, I changed the wait-on URL in amplify.yml to http://172.17.0.2:3000. When the dev server serves from that url, the cypress test command runs.

And hangs indefinitely. Again. This is the log from the test tab.

                                 # Starting phase: preTest
                                 # Executing command: npm install
2019-11-13T09:01:56.994Z [WARNING]: npm WARN
2019-11-13T09:01:56.998Z [WARNING]: [email protected] requires a peer of graphql@^0.11.0 but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-11-13T09:01:56.999Z [INFO]: audited 909009 packages in 7.89s
                                 found 0 vulnerabilities
2019-11-13T09:01:57.007Z [INFO]: # Executing command: npm install wait-on
2019-11-13T09:02:06.093Z [INFO]: > [email protected] postinstall /codebuild/output/src654400301/src/app/node_modules/wait-on/node_modules/core-js
                                 > node postinstall || echo "ignore"
2019-11-13T09:02:07.307Z [WARNING]: npm
2019-11-13T09:02:07.312Z [WARNING]: WARN [email protected] requires a peer of graphql@^0.11.0 but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-11-13T09:02:07.313Z [INFO]: + [email protected]
                                 added 3 packages from 2 contributors and audited 909082 packages in 9.96s
                                 found 0 vulnerabilities
2019-11-13T09:02:07.323Z [INFO]: # Executing command: npm install  [email protected] mochawesome mochawesome-merge mochawesome-report-generator
2019-11-13T09:02:19.432Z [WARNING]: npm WARN [email protected] requires a peer of graphql@^0.11.0 but none is installed. You must install peer dependencies yourself.
2019-11-13T09:02:19.434Z [WARNING]: npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
                                    npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                                    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2019-11-13T09:02:19.435Z [INFO]: + [email protected]
                                 + [email protected]
                                 + [email protected]
                                 + [email protected]
                                 added 58 packages from 453 contributors and audited 909384 packages in 11.777s
                                 found 0 vulnerabilities
2019-11-13T09:02:19.447Z [INFO]: # Executing command: npm start & npx wait-on http://172.17.0.2:3000
2019-11-13T09:02:19.638Z [INFO]: > [email protected] start /codebuild/output/src654400301/src/app
                                 > react-scripts start
2019-11-13T09:02:20.883Z [INFO]: Starting the development server...
2019-11-13T09:02:34.178Z [INFO]: Compiled successfully!
2019-11-13T09:02:34.180Z [INFO]: You can now view frontend in the browser.
                                 Local:            http://localhost:3000/
                                 On Your Network:  http://172.17.0.2:3000/
                                 Note that the development build is not optimized.
                                 To create a production build, use yarn build.
2019-11-13T09:02:35.431Z [INFO]: # Completed phase: preTest
                                 # Starting phase: test
2019-11-13T09:02:35.432Z [INFO]: # Executing command: npx cypress run --record --reporter mochawesome --reporter-options reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss

This looks like a bug with Amplify, but it's also possible that Cypress WANTS to run on http://127.0.0.1:8080 and since it isn't, it hangs. And we're in this situation because Amplify won't run the dev server where Cypress expects.

Suggestions?

I tried setting an environment variable for the URL being used by Cypress for the dev server.

CYPRESS_BASE_URL    http://172.17.0.2:3000

Still hangs forever.

I removed the --record flag for the time being on Cypress and this happened.

2019-11-13T09:43:31.101Z [INFO]: # Executing command: npx cypress run --reporter mochawesome --reporter-options reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss
2019-11-13T09:43:31.377Z [INFO]: The cypress npm package is installed, but the Cypress binary is missing.
                                 We expected the binary to be installed here: /root/.cache/Cypress/3.6.1/Cypress/Cypress
                                 Reasons it may be missing:
                                 - You're caching 'node_modules' but are not caching this path: /root/.cache/Cypress
                                 - You ran 'npm install' at an earlier build step but did not persist: /root/.cache/Cypress
                                 Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
                                 Alternatively, you can run 'cypress install' to download the binary again.
                                 https://on.cypress.io/not-installed-ci-error
                                 ----------
                                 Platform: linux (Raspbian - 2)
                                 Cypress Version: 3.6.1

As per the instructions at that link in the Cypress docs (even though their kitchen sink amplify.yml file has node_modules cached), I removed node_modules from the amplify.yml cache, and changed it to this:

  cache:
    paths:
      - ~/.cache

I no longer get the above error from Cypress, but it hangs indefinitely again when it hits npx cypress run.

2019-11-13T10:01:12.737Z [INFO]: Starting the development server...
2019-11-13T10:01:27.893Z [INFO]: Compiled successfully!
2019-11-13T10:01:27.895Z [INFO]: You can now view frontend in the browser.
                                 Local:            http://localhost:3000/
                                 On Your Network:  http://172.17.0.2:3000/
                                 Note that the development build is not optimized.
                                 To create a production build, use yarn build.
2019-11-13T10:01:29.403Z [INFO]: # Completed phase: preTest
                                 # Starting phase: test
2019-11-13T10:01:29.405Z [INFO]: # Executing command: npx cypress run --reporter mochawesome --reporter-options reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss

It feels like I'm just spinning my wheels here.

  • The Cypress docs say one thing
  • Their amplify.yml says the opposite thing
  • Their error in the log says that their amplify.yml is wrong
  • The documentation page link in their error also says their amplify.yml is wrong
  • Changing it to what their documentation says it should be gets me back to where I started - indefinite hanging

🤷🏻‍♂️

@stevensacks , sorry you're having a hard time getting your tests to work. We're currently investigating this issue. We will follow up with you shortly.

Thank you. I made a public repo that is essentially the same project (with the code that is specific to the amplify backend on my org’s AWS account removed).

https://github.com/stevensacks/amplify-test

Hello @stevensacks
Thank you for providing the code.
When I worked on amplify-test, I changed theamplify.yml to :

version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
test:
  artifacts:
    baseDirectory: cypress
    configFilePath: '**/mochawesome.json'
    files:
      - '**/*.png'
      - '**/*.mp4'
  phases:
    preTest:
      commands:
        - npm install
        - npm install wait-on
        - npm install  [email protected] mochawesome mochawesome-merge mochawesome-report-generator
        - 'npm start & npx wait-on http://localhost:3000'
    test:
      commands:
        - 'npx cypress run --reporter mochawesome --reporter-options "reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss"'
    postTest:
      commands:
        - npx mochawesome-merge --reportDir cypress/report/mochawesome-report > cypress/report/mochawesome.json

(I didn't add any environment variables.)

It works on my amplify console.
Can you try it to see if it works on your application? If not, please let us know. Thanks!

Wow. http://localhost:3000 worked! Thanks @Joycehao19 !

So Cypress is now technically working, but the output looks nothing like the screenshot.

This is what it's supposed to look like (a nice UI list):
image

But this is what mine looks like (noise garbage):
Screen Shot 2019-11-17 at 13 23 25

What is causing this?

Hi @stevensacks , when I worked on amplify-test, the test section showed a list of results as it's supposed to look like.

When you test your code locally, did you get the expected UI list?

I ran into this issue as well, and resolved it with the recommended tweak (Thank you!!!):

Also, though, I needed to make sure I had a cypress.json file in the root of my project with:

{
"baseUrl": "http://localhost:3000/"
}

Without that, Console timed-out in the test phase of the build.

Closing this issue. If you encounter something in the future please reach out.

I am seeing this very issue after one or two successful builds. Nothing changed other than a minor tweak to a test and now it hangs when attempting to run Cypress. No error is given it just hangs.

I've tried different ports and various other tweaks but so far nothing will get it running again.

@Joycehao19 Sorry for the delay getting back with you.

When I run it locally, I see my login.spec.js as expected.

Cypress Local

I have the cypress.json file in the root of my project with "baseUrl": "http://localhost:3000/".

I have spent a few hours trying to figure out what is going on with my build. It worked correctly initially but nothing I do now will get it past hanging on running Cypress.

I've curled the server to check for a response and it looks to be running fine. I've tried an Express server and the CRA Server. The same code is currently working correctly with a custom Bitbucket Pipeline so I know it works fine outside of the Amplify stack.

I spent some time trying to get rid of wait-on command, and replacing it with start-server-and-test. Finally it is working!

Install start-server-and-test:

yarn add start-server-and-test --dev

Modify amplify.yml file:

version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
test:
  artifacts:
    baseDirectory: cypress
    configFilePath: '**/mochawesome.json'
    files:
      - '**/*.png'
      - '**/*.mp4'
  phases:
    preTest:
      commands:
        - yarn install
        - yarn add mocha mochawesome mochawesome-merge mochawesome-report-generator
    test:
      commands:
        - npx start-test 'yarn start' 3000 'npx cypress run --reporter mochawesome --reporter-options "reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss"'
    postTest:
      commands:
        - npx mochawesome-merge cypress/report/mochawesome-report/mochawesome*.json > cypress/report/mochawesome.json

Besides other comments I have added env variable with "CI=true" in amplify console, otherwise Test hangs on Starting Development Server..

Was this page helpful?
0 / 5 - 0 ratings