question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

zone.js fails to patch mocha v8.3.1 and up

See original GitHub issue

Which @angular/* package(s) are the source of the bug?

Don’t known / other

Is this a regression?

No

Description

I’ve created a fresh Angular 12 project with the CLI, refactored tests to use Mocha instead of Jasmine and the tests failed.

  • Clone the repo and run npm test - everything will work fine
  • Open package.json and set the mocha dependency to 8.3.1 or higher, then run npm test again
  • You’ll now get the exception below.

Please provide a link to a minimal reproduction of the bug

https://github.com/Alorel/zone.js-mocha-patch-bug-reproduction

Please provide the exception or error you saw

RangeError: Maximum call stack size exceeded
      at wrapTestInZone (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:1024:1)
      at global.beforeEach.global.setup.Mocha.beforeEach (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:1077:1)
      at exports.beforeEach (node_modules/mocha/mocha.js:28402:65)
      at global.beforeEach.global.setup.Mocha.beforeEach (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:1077:1)
      at exports.beforeEach (node_modules/mocha/mocha.js:28402:65)
      at global.beforeEach.global.setup.Mocha.beforeEach (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:1077:1)
      at exports.beforeEach (node_modules/mocha/mocha.js:28402:65)
      at global.beforeEach.global.setup.Mocha.beforeEach (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:1077:1)
      at exports.beforeEach (node_modules/mocha/mocha.js:28402:65)
      at global.beforeEach.global.setup.Mocha.beforeEach (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:1077:1)

Please provide the environment you discovered this bug in

Angular CLI: 12.1.1
Node: 14.16.1
Package Manager: npm 7.11.2
OS: linux x64

Angular: 12.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.1
@angular-devkit/build-angular   12.1.1
@angular-devkit/core            12.1.1
@angular-devkit/schematics      12.1.1
@schematics/angular             12.1.1
rxjs                            6.6.7
typescript                      4.3.5

Anything else?

The zone.js version is 0.11.4. The same happens on Angular 11 and zone 0.11.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
crfrolikcommented, Oct 28, 2021

Would it be possible to get this prioritized? It will impact anyone using Mocha with Angular unit tests.

See also: https://github.com/mochajs/mocha/issues/4660#issuecomment-953988083

3reactions
JiaLiPassioncommented, Feb 18, 2022

@juergba , I am not sure about the release schedule, I will plan to cut a new release after several other issues of zone.js are fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocha Testing Angular referenceError: Zone is not defined
I tried to import 'zone.js' inside my test code but it had no affect. Would anyone know how to bypass or fix this...
Read more >
cannot read properties of undefined (reading 'data') axios
This error originates from swr/dist/index.mjs at line 153. Update. This error only occurred to me when @mux/mux-video-react was installed. Expected Behavior.
Read more >
A Brief History of JavaScript - Auth0
We take a look at the evolution of JavaScript, arguably one of the most important languages of today, and tomorrow.
Read more >
gun - node_modules - mocha - CHANGELOG.md
:warning: Due to the increasing difficulty of applying security patches made within its dependency tree, as well as looming incompatibilities ...
Read more >
Firebase JavaScript SDK Release Notes - Google
The earlier update in version 9.13.0 upgraded TypeScript only in the root. ... The v8 SDK is updated only for emergency security fixes,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found