angular-cli: Unit tests produce the error "Some of your tests did a full page reload!" after Chrome update

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

core

Is this a regression?

No

Description

I don’t believe is an Angular issue, but I’m creating this report for clarity and to increase visibility.

Since updating to Chrome ~128.x running unit tests produce an error in spite of all tests passing. To reproduce you can simply create a new project and run ng test.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Chrome Headless 128.0.0.0 (Mac OS 10.15.7) ERROR
  Some of your tests did a full page reload!
Chrome Headless 128.0.0.0 (Mac OS 10.15.7): Executed 4129 of 4129 SUCCESS (18.521 secs / 17.638 secs)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.3.8
Node: 18.20.4
Package Manager: npm 10.7.0
OS: darwin arm64

Angular: 17.3.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1703.8
@angular-devkit/build-angular      17.3.8
@angular-devkit/core               17.3.8
@angular-devkit/schematics         17.3.8
@angular-devkit/schematics-cli     17.3.8
@angular/cdk                       17.3.10
@angular/cli                       17.3.8
@angular/flex-layout               15.0.0-beta.42
@angular/material                  17.3.10
@angular/material-moment-adapter   17.3.10
@schematics/angular                17.3.8
ng-packagr                         17.3.0
rxjs                               7.8.1
typescript                         5.3.3
zone.js                            0.14.7

Anything else?

I tested it out on new Angular 17 and 18 projects using node 18 and 20 and get the same results for all of them. I was able to verify that upon reverting to Chrome 127.x the error is not produced.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 20
  • Comments: 22 (1 by maintainers)

Commits related to this issue

Most upvoted comments

@alan-agius4 was able to reproduce the issue in a base Karma setup without Angular, so that at least rules out Angular as the root cause here: https://github.com/karma-runner/karma/issues/3887

That said, setting clearContext: singleRun seems to be a reasonable workaround, so we released that as a default behavior for Angular in all actively supported versions (16.2.15, 17.3.9, 18.2.2). We expect that will resolve the symptoms of the issue for most developers. If you have a custom Karma config and that explicitly sets clearContext, you may need to remove that or manually set it to true when singleRun === true.

Beyond that, hopefully the Karma and/or Chrome teams can figure out what’s going on under the hood here, as there’s definitely a deeper root cause which is not understood by us right now.

Related? https://github.com/karma-runner/karma/issues/3560#issuecomment-1999290275

I set clearContext: config.singleRun in my local karma.config and the error goes away…

I also have this issue. I’m only commenting to add that I ONLY see the problem in non-watch mode : ng test --watch=false

image

I encountered the same issue today on our CI environment. It was fine locally with chrome 128, headless or not. But I’m running Windows. Our CI pipeline runs Mac OS though.

I was able to fix it by adding the following beforeAll code. Basically just preventing any redirects. image

It changed the CI output from the left (failing) to the right (succeeding) image

Related? karma-runner/karma#3560 (comment)

I set clearContext: config.singleRun in my local karma.config and the error goes away…

This works for me.

Environment:

Angular 17
macOS Sonoma

@dgp1130, I was able to replicate this issue exclusively on macOS, and it occurs in both headless and non-headless modes of Chrome version 128.0.0.0.

When --watch is set to a non-truthy value, I also observed the Some of your tests did a full page reload! error appearing when the browser closes after all tests have successfully run. However, in my case, the process did not terminate with a non-zero exit code.

It caused my pre-push hook to fail and I had to switch off the hooks to be able to push so for us it appears to be actually causing a non-zero exit.

Related? karma-runner/karma#3560 (comment)

I set clearContext: config.singleRun in my local karma.config and the error goes away…

In my case I did the same but still getting the error