【发布时间】:2021-01-01 01:21:27
【问题描述】:
我正在 NX 角度工作区中编写单元测试。有时它会给出这样的错误:
(node:15320) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'element' -> object with constructor 'Object'
| property 'componentProvider' -> object with constructor 'Object'
--- property 'parent' closes the circle
at stringify (<anonymous>)
at writeChannelMessage (internal/child_process/serialization.js:117:20)
at process.target._send (internal/child_process.js:779:17)
at process.target.send (internal/child_process.js:677:19)
at reportSuccess (C:\Users\INFINTY\angular\nfx__1-sep\node_modules\jest-runner\node_modules\jest-worker\build\workers\processChild.js:67:11)
(node:15320) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15320) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
它没有显示确切的错误。我知道 jasmine/karma 中有一个命令强制测试以显示正确的错误,但我忘记了。谁能帮助我,我怎样才能在 jest/cypress 中得到确切的错误。
【问题讨论】:
-
遇到同样的错误,到目前为止还没有找到解决方案。
-
@george,。这个错误基本上是spec.ts中的一些其他错误。注释 spec 文件中的所有代码,然后逐行取消注释。
-
正确。在我的情况下,这个错误是通过在我的测试模块中从ngrx 导入
EffectsModule.forRoot()引起的 -
我见过很多人报告此错误,并且每个人都将其归因于一件事或另一件事,根据我的观察,这实际上似乎是 Jest 记者中的某种竞争条件导致间歇性错误跨度>
-
我已将此问题添加到 NX 问题列表中:github.com/nrwl/nx/issues/3973 - 因为这开始于 @nrwl/workspace 的最新更新(与 JEST 26 相关)