【发布时间】:2023-04-05 06:09:01
【问题描述】:
我在开发者工具中不断收到这个错误,在过去的几天里它一直在驱使我。
Unhandled Promise rejection: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
因此,我已经阅读并尝试了几乎所有与修复涉及 Zone.js 的 Unhandled Promise 拒绝错误相关的所有内容,但均无济于事。 所有错误似乎都指向我的 shim.min.js 文件,但似乎无论我以什么顺序加载文件,错误仍然存在!
这是我所有的相关文件:
这是我的 polyfill.ts 文件:
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
这是我的 test.ts 文件:
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any;
declare var require: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function () {};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
__karma__.start();
如果您想查看任何其他文件,请告诉我!
非常感谢任何帮助!
【问题讨论】:
标签: node.js angular promise unhandled zone.js