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!