Skip to content

testing setup using chai, mocha and mongo mock server #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2019

Conversation

Keda87
Copy link
Owner

@Keda87 Keda87 commented Jul 14, 2019

Still having an issue when running the test

$ docker-compose run api yarn test

error logs:

(node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecti
ng a promise which was not handled with .catch(). (rejection id: 3)
(node:23) UnhandledPromiseRejectionWarning: Error: spawn Unknown system error -8
    at ChildProcess.spawn (internal/child_process.js:358:11)
    at Object.spawn (child_process.js:538:9)
    at Object.spawn [as default] (/sourcecode/node_modules/cross-spawn/index.js:12:24)
    at MongoInstance._launchMongod (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:198:49)
    at MongoInstance.<anonymous> (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:134:50)
    at step (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:43:23)
    at Object.next (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:24:53)
    at fulfilled (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:15:58)
(node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
    1) "before all" hook for "OK, Create new task is success"


  0 passing (2s)
  1 failing

  1) POST /tasks
       "before all" hook for "OK, Create new task is success":
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/sourcecode/dist/tests/api/task/post.js)

@Keda87 Keda87 mentioned this pull request Jul 14, 2019
@Keda87 Keda87 force-pushed the feature/implement-test branch 2 times, most recently from 33b0b7d to bab01ff Compare July 14, 2019 15:51
@Keda87
Copy link
Owner Author

Keda87 commented Jul 14, 2019

Still having an issue when running the test

$ docker-compose run api yarn test

error logs:

(node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecti
ng a promise which was not handled with .catch(). (rejection id: 3)
(node:23) UnhandledPromiseRejectionWarning: Error: spawn Unknown system error -8
    at ChildProcess.spawn (internal/child_process.js:358:11)
    at Object.spawn (child_process.js:538:9)
    at Object.spawn [as default] (/sourcecode/node_modules/cross-spawn/index.js:12:24)
    at MongoInstance._launchMongod (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:198:49)
    at MongoInstance.<anonymous> (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:134:50)
    at step (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:43:23)
    at Object.next (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:24:53)
    at fulfilled (/sourcecode/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:15:58)
(node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
    1) "before all" hook for "OK, Create new task is success"


  0 passing (2s)
  1 failing

  1) POST /tasks
       "before all" hook for "OK, Create new task is success":
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/sourcecode/dist/tests/api/task/post.js)

This issue solved following this typegoose/mongodb-memory-server#171 (comment)

@Keda87
Copy link
Owner Author

Keda87 commented Jul 14, 2019

Got another issue and still not resolved

  0 passing (329ms)
  1 failing

  1) POST /tasks
       "before all" hook for "OK, Create new task is success":
     MongooseError: You can not `mongoose.connect()` multiple times while connected.
      at new MongooseError (node_modules/mongoose/lib/error/mongooseError.js:10:11)
      at Mongoose.connect (node_modules/mongoose/lib/index.js:292:11)
      at /sourcecode/dist/models/index.js:30:30
      at process._tickCallback (internal/process/next_tick.js:68:7)

@Keda87 Keda87 added the help wanted Extra attention is needed label Jul 14, 2019
@Keda87 Keda87 force-pushed the feature/implement-test branch 2 times, most recently from 70f931f to 2397a1c Compare July 17, 2019 23:12
@Keda87 Keda87 force-pushed the feature/implement-test branch from 2397a1c to 0af06aa Compare July 17, 2019 23:43
@Keda87
Copy link
Owner Author

Keda87 commented Jul 17, 2019

Got this error TypeError: Cannot read property 'address' of undefined when running the test.
solved following this link https://stackoverflow.com/a/39544611/1936697

@Keda87 Keda87 marked this pull request as ready for review July 17, 2019 23:45
@Keda87 Keda87 changed the title [WIP] testing setup using chai, mocha and mongo mock server testing setup using chai, mocha and mongo mock server Jul 17, 2019
@Keda87 Keda87 merged commit e066c8c into develop Jul 17, 2019
@Keda87 Keda87 deleted the feature/implement-test branch July 17, 2019 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant