'After update to angular 13 my tests are not running

When trying to run my tests after migrating to angular 13 I get the following error. The tests were running just fine in angular 12.

START:
07 02 2022 16:10:25.729:INFO [karma-server]: Karma v6.3.15 server started at http://localhost:9876/
07 02 2022 16:10:25.746:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency 1
07 02 2022 16:10:25.773:INFO [launcher]: Starting browser ChromeHeadless
07 02 2022 16:10:49.143:INFO [Chrome Headless 97.0.4692.99 (Mac OS 10.15.7)]: Connected on socket zvPwcmTYYjIqiX_xAAAB with id 50531189
Chrome Headless 97.0.4692.99 (Mac OS 10.15.7) ERROR
  Uncaught ReferenceError: global is not defined
  at http://localhost:9876/_karma_webpack_/polyfills.js:195:1

  ReferenceError: global is not defined
      at Module.7435 (http://localhost:9876/_karma_webpack_/polyfills.js:195:1)
      at __webpack_require__ (http://localhost:9876/_karma_webpack_/runtime.js:23:42)
      at __webpack_exec__ (http://localhost:9876/_karma_webpack_/polyfills.js:10358:48)
      at http://localhost:9876/_karma_webpack_/polyfills.js:10359:37
      at webpackJsonpCallback (http://localhost:9876/_karma_webpack_/runtime.js:323:39)
      at http://localhost:9876/_karma_webpack_/polyfills.js:1:67

I have defined (window as any)['global'] = window;in my src/pollyfills.js

Does anyone have an idea what could be causing this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source