我正在 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 中有一个命令强制测试显示正确的错误,但我忘记了。任何人都可以帮助我,我怎样才能在笑话/赛普拉斯中得到确切的错误。
在我的应用程序中,只需导入HttpClientModule
进入测试文件(HttpClient
正在该组件中使用):
import { HttpClientModule } from '@angular/common/http';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HttpClientModule, RouterTestingModule],
declarations: [AppComponent],
}).compileComponents();
});
});
我在用着:
- 角度 10.1.4
- 开玩笑 26.6.0
- 笑话预设角度 8.3.1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)