Inconsistency between CircleCI Local CLI and CircleCI online version

Hi, I have been facing some inconsistencies when trying to use mocha and chai to run my tests.
Using the CircleCI Local CLI my tests are successful, however, on the online version the same tests are falling.

My config File
version: 2

    jobs:

      build:
        docker:
          - image: circleci/node:9.5-browsers
            environment:
              PGHOST: 127.0.0.1
              PGUSER: rhuan
              NODE_ENV: test
              PORT: 8080
          - image: circleci/postgres:9.6.2-alpine
            environment:
              POSTGRES_DB: bilibiosTesting
              POSTGRES_PASSWORD: ""
              POSTGRES_USER: rhuan
          
        working_directory: ~/repo

        steps:
          - checkout

          - restore_cache:
              keys:
              - v1-dependencies-{{ checksum "package.json" }}
              - v1-dependencies-
              
          - run: yarn install
          
          - run: yarn global add sequelize-cli
          - run: 
              name: migrating database
              command: cd api/db && ../../node_modules/.bin/sequelize db:migrate

          - save_cache:
              paths:
                - ./node_modules
              key: v1-dependencies-{{ checksum "package.json" }}

          ## API
          - restore_cache:
              keys:
              - v2-dependencies-{{ checksum "package.json" }}
              - v2-dependencies-

          - run:
              name: React install dependencies
              command: cd client && yarn install
          

          #CLIENT CACHE
          - save_cache:
              paths:
                - ./client/node_modules
              key: v2-dependencies-{{ checksum "./client/package.json" }}


          # run tests!
          - run: sleep 5 && yarn run test

          - run:
              name: Getting react ready for production
              command: cd client && yarn build


      deploy-staging:
        machine:
          enabled: true
        working_directory: ~/repo
        #environment:
        steps:
          - checkout
          - run: bash deploy-staging.sh


      deploy-production:
        machine:
          enabled: true
        working_directory: ~/repo
        #environment:
        steps:
          - checkout
          - run: bash deploy-production.sh

    workflows:
      version: 2
      build-and-deploy:
        jobs:
          - build
          - deploy-staging:
              requires:
                - build
              filters:
                branches:
                  only: dev
          - deploy-production:
              requires:
                - build
                - deploy-staging
              filters:
                branches:
                  only: master

Result using the CircleCI Local CLI

  info: Server is runing on port  8080
  AirBnB Style Guide Adhearance - eslint
    āœ“ should have no errors in api/controllers/adminDashboard.js
    āœ“ should have no errors in api/controllers/auth.js
    āœ“ should have no errors in api/controllers/branch.js
    āœ“ should have no errors in api/controllers/passaport.js
    āœ“ should have no errors in api/controllers/root.js
    āœ“ should have no errors in test/_eslint.js
    āœ“ should have no errors in test/api/login.js
    āœ“ should have no errors in test/api/server.js
    āœ“ should have no errors in test/env.js
    āœ“ should have no errors in client/src/actions/index.js
    āœ“ should have no errors in client/src/components/auth.js
    āœ“ should have no errors in client/src/components/box.js
    āœ“ should have no errors in client/src/components/common/index.js
    āœ“ should have no errors in client/src/components/common/nav.js
    āœ“ should have no errors in client/src/container/auth-container.js
    āœ“ should have no errors in client/src/container/box-container.js
    āœ“ should have no errors in client/src/container/home.js
    āœ“ should have no errors in client/src/index.js

  /auth/sign-up | POST
Executing (default): SELECT "id", "email", "username", "password", "resetPasswordToken", "resetPasswordExpires", "createdAt", "updatedAt" FROM "users" AS "users" WHERE "users"."username" = 'rhuan' LIMIT 1;
Executing (default): INSERT INTO "users" ("id","email","username","password","createdAt","updatedAt") VALUES (DEFAULT,'rhuansantosdev@gmail.com','rhuan','$2a$10$de/KEGu8Kskk54lF3opeuePLvyki8Y8/J4taZIKwINyaJw77Lsemu','2018-04-30 20:34:04.851 +00:00','2018-04-30 20:34:04.851 +00:00') RETURNING *;
Executing (default): SELECT "id", "email", "username", "password", "resetPasswordToken", "resetPasswordExpires", "createdAt", "updatedAt" FROM "users" AS "users" WHERE "users"."username" = 'rhuan' LIMIT 1;
    āœ“ it should create an user (1382ms)


  19 passing (2s)

Result using Circleci online

info: Server is runing on port  8080
  AirBnB Style Guide Adhearance - eslint
    āœ“ should have no errors in api/controllers/adminDashboard.js (1042ms)
    āœ“ should have no errors in api/controllers/auth.js
    āœ“ should have no errors in api/controllers/branch.js
    āœ“ should have no errors in api/controllers/passaport.js
    āœ“ should have no errors in api/controllers/root.js
    āœ“ should have no errors in test/_eslint.js
    āœ“ should have no errors in test/api/login.js
    āœ“ should have no errors in test/api/server.js
    āœ“ should have no errors in test/env.js
    āœ“ should have no errors in client/src/actions/index.js
    āœ“ should have no errors in client/src/components/auth.js
    āœ“ should have no errors in client/src/components/box.js
    āœ“ should have no errors in client/src/components/common/index.js
    āœ“ should have no errors in client/src/components/common/nav.js
    āœ“ should have no errors in client/src/container/auth-container.js
    āœ“ should have no errors in client/src/container/box-container.js
    āœ“ should have no errors in client/src/container/home.js
    āœ“ should have no errors in client/src/index.js

  /auth/sign-up | POST
Executing (default): SELECT "id", "email", "username", "password", "resetPasswordToken", "resetPasswordExpires", "createdAt", "updatedAt" FROM "users" AS "users" WHERE "users"."username" = 'rhuan' LIMIT 1;
Executing (default): INSERT INTO "users" ("id","email","username","password","createdAt","updatedAt") VALUES (DEFAULT,'rhuansantosdev@gmail.com','rhuan','$2a$10$oZpR3SX5vnfYwHTF8HlANu5VWDF.PALPMW9xmacBB1PAl8UIURiye','2018-04-30 20:38:46.414 +00:00','2018-04-30 20:38:46.414 +00:00') RETURNING *;
Executing (default): SELECT "id", "email", "username", "password", "resetPasswordToken", "resetPasswordExpires", "createdAt", "updatedAt" FROM "users" AS "users" WHERE "users"."username" = 'rhuan' LIMIT 1;
    1) it should create an user


  18 passing (12s)
  1 failing

  1) /auth/sign-up | POST
      it should create an user:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  



error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1

Note: running mocha and chai without circle Ci the tests are also successful, I have tried multiple ports but the tests on the online version keeps falling

Thanks!

1 Like

Most importantly, copy & pasting as much of your config as possible as well as the output of circleci version from your local machine. Thank you.

1 Like

Hi @halfer I just update the post as you requested!

Circleci local version
0.0.4994-4605912

Marvellous, thanks. Iā€™m a JS ignoramus, but Iā€™d start off with comparing the versions of Node, Yarn, Mocha and Chai.

Also, does this start up a real Node server? If so, maybe SSH into the box, try running the tests again, and use another SSH session to see if the server process is listening? I imagine you can put a sleep in one of your tests to give you more time to explore.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.