Javascript 捕获的错误显示在控制台中

Javascript 捕获的错误显示在控制台中,javascript,mocha.js,graphql,apollo,feathersjs,Javascript,Mocha.js,Graphql,Apollo,Feathersjs,我的项目有两个测试: "Foods can be fetched when authenticated" "can not be fetched when not authenticated" 问题在于第二次测试。它需要一个被try/catch statemet截获的错误。因此,我不希望控制台中抛出错误,但它确实会 同样的问题也适用于直接使用承诺 我一直在挖掘Graphql和Feathers的源代码,自己解决了这个问题,但没有成功 我已创建了最低可复制代码: 控制台输出 Test info:

我的项目有两个测试:

"Foods can be fetched when authenticated"

"can not be fetched when not authenticated"
问题在于第二次测试。它需要一个被try/catch statemet截获的错误。因此,我不希望控制台中抛出错误,但它确实会

同样的问题也适用于直接使用承诺

我一直在挖掘Graphql和Feathers的源代码,自己解决了这个问题,但没有成功

我已创建了最低可复制代码:

控制台输出

Test
info: after: users - Method: create
info: after: users - Method: find
info: after: authentication - Method: create
info: after: foods - Method: remove
    foods
info: after: foods - Method: create
info: after: foods - Method: create
info: after: foods - Method: create
info: after: users - Method: get
info: after: users - Method: get
info: after: foods - Method: find
      ✓ can be fetched when authenticated (81ms)
info: error: foods - Method: find: No auth token
error:  NotAuthenticated: No auth token
    at NotAuthenticated (/home/$USER/Desktop/examples/node_modules/feathers-errors/lib/index.js:100:17)
    at /home/$USER/Desktop/examples/node_modules/feathers-authentication/lib/hooks/authenticate.js:102:31
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
NotAuthenticated: No auth token
    at NotAuthenticated (/home/$USER/Desktop/examples/node_modules/feathers-errors/lib/index.js:100:17)
    at /home/$USER/Desktop/examples/node_modules/feathers-authentication/lib/hooks/authenticate.js:102:31
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
      ✓ can not be fetched when not authenticated

  'foods' service
    ✓ registered the service


  3 passing (1s)
测试
信息:在:用户之后-方法:创建
信息:在:用户之后-方法:查找
信息:之后:身份验证-方法:创建
信息:食物之后-方法:移除
食品
信息:在:食物之后-方法:创建
信息:在:食物之后-方法:创建
信息:在:食物之后-方法:创建
信息:after:users-方法:get
信息:after:users-方法:get
信息:在:食物之后-方法:查找
✓ 可在经过身份验证时提取(81ms)
信息:错误:foods-方法:find:无身份验证令牌
错误:未验证:没有验证令牌
未经验证(/home/$USER/Desktop/examples/node_modules/feathers errors/lib/index.js:100:17)
at/home/$USER/Desktop/examples/node_modules/feathers authentication/lib/hooks/authenticate.js:102:31
在
在进程中。_tick回调(内部/process/next_tick.js:188:7)
未验证:没有验证令牌
未经验证(/home/$USER/Desktop/examples/node_modules/feathers errors/lib/index.js:100:17)
at/home/$USER/Desktop/examples/node_modules/feathers authentication/lib/hooks/authenticate.js:102:31
在
在进程中。_tick回调(内部/process/next_tick.js:188:7)
✓ 未经身份验证时无法获取
“食品”服务
✓ 注册服务
3次通过(1s)
您(或其他人)已经在这里问过同样的问题:您(或其他人)已经在这里问过同样的问题:
Test
info: after: users - Method: create
info: after: users - Method: find
info: after: authentication - Method: create
info: after: foods - Method: remove
    foods
info: after: foods - Method: create
info: after: foods - Method: create
info: after: foods - Method: create
info: after: users - Method: get
info: after: users - Method: get
info: after: foods - Method: find
      ✓ can be fetched when authenticated (81ms)
info: error: foods - Method: find: No auth token
error:  NotAuthenticated: No auth token
    at NotAuthenticated (/home/$USER/Desktop/examples/node_modules/feathers-errors/lib/index.js:100:17)
    at /home/$USER/Desktop/examples/node_modules/feathers-authentication/lib/hooks/authenticate.js:102:31
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
NotAuthenticated: No auth token
    at NotAuthenticated (/home/$USER/Desktop/examples/node_modules/feathers-errors/lib/index.js:100:17)
    at /home/$USER/Desktop/examples/node_modules/feathers-authentication/lib/hooks/authenticate.js:102:31
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
      ✓ can not be fetched when not authenticated

  'foods' service
    ✓ registered the service


  3 passing (1s)