Search code examples
cypresscreate-react-appcirclecicraco

Circle Ci - Start react server and test via cypress


I'm running cypress on a server started in cirleci script. Though cypress can't seam to find the local server that I just started. Here's my scripts / setup. I've also tried the cypress circlci-orb and get the same error, so was trying run things myself to help debug. Here's the script details:

  - run:
      name: 'Run app tests'
      command: |
        cd app
        yarn install --frozen-lockfile
        yarn lint
        yarn cypress:ci

package.json script:

"cypress:ci": "CYPRESS_BASE_URL=http://localhost:3000 yarn start & wait-on http-get://localhost:3000 && cypress run"

Error:

$ craco start
ℹ 「wds」: Project is running at http://192.168.208.3/
ℹ 「wds」: webpack output is served from 
ℹ 「wds」: Content not from webpack is served from /root/project/app/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...

.....
react startup output
......

Cypress tests are kicked off and get the following error

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

  > Error: connect ECONNREFUSED 127.0.0.1:3000


Solution

  • The solution: Up your resource class! In your circleci/config.yml

    jobs:
      continuous-integration:
        resource_class: large
    

    It was non obvious as there were no memory/resource warnings, but according to the circle ci team:

    When the machine runs out of memory processes are killed which could include the server.

    That server was the cra-server i was trying to start. I upped the resource class and voilà it ran and was found by cypress! In our case we bumped it from a medium to a large class, but may be different for you.

    Here's the available resource classes you can use:

    https://circleci.com/product/features/resource-classes/