Skip to content

Running npm test logs an error but does not fail the tests #35

@Furchin

Description

@Furchin

The error is:

node:30504) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'logger' of undefined
    at error (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/swatchjs-koa-middleware/dist/lib/response/index.js:57:10)
    at setResponse (/Users/furchin/Documents/BFM/swatchjs-koa/lib/response.js:1:28)
    at Object._callee$ (/Users/furchin/Documents/BFM/swatchjs-koa/lib/defaults.js:3:55)
    at tryCatch (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:299:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/furchin/Documents/BFM/swatchjs-koa/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (<anonymous>)
    at new F (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/core-js/library/modules/_export.js:35:28)
    at Object.<anonymous> (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
    at Object.authMiddleware [as authAdapter] (/Users/furchin/Documents/BFM/swatchjs-koa/lib/defaults.js:3:340)
    at Context.<anonymous> (/Users/furchin/Documents/BFM/swatchjs-koa/test/defaults.test.js:153:25)
    at callFn (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/mocha/lib/runnable.js:348:21)
    at Test.Runnable.run (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/mocha/lib/runnable.js:340:7)
    at Runner.runTest (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/mocha/lib/runner.js:443:10)
    at /Users/furchin/Documents/BFM/swatchjs-koa/node_modules/mocha/lib/runner.js:549:12
    at next (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/mocha/lib/runner.js:361:14)
    at /Users/furchin/Documents/BFM/swatchjs-koa/node_modules/mocha/lib/runner.js:371:7
    at next (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/mocha/lib/runner.js:295:14)
    at Immediate._onImmediate (/Users/furchin/Documents/BFM/swatchjs-koa/node_modules/mocha/lib/runner.js:339:5)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)
(node:30504) 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: 6)

There are two concerns here:

  1. The error itself should be fixed.
  2. The tests should fail when an unhandled promise rejection occurs.

In reality we ought to fix the latter issue first, confirm the tests begin failing, then fix the error itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions