Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Some of your tests did a full page reload!" on MacOS when using Chrome 128.x #3887

Open
alan-agius4 opened this issue Aug 29, 2024 · 2 comments

Comments

@alan-agius4
Copy link
Contributor

From angular/angular-cli#28271

When using Karma with Chrome 128.x on OSX, the following error is displayed: Some of your tests did a full page reload!.

Reproduction steps

mkdir karma-test
cd karma-test
npm init -y
npm install karma karma-chrome-launcher karma-jasmine --save-dev 
npx karma init

Update the karma config to include

  client: {
    clearContext: false,
  },
npx karma start —-single-run
@mufniarz
Copy link

mufniarz commented Oct 8, 2024

// This works for me. Not sure if it's a good option or if it makes more sense to address this in the config.

beforeEach(async () => {
    window.onbeforeunload = () => "Oh no!"; // Prevent page reloads during tests
});

It’s recommended to use this as a temporary workaround while investigating the root cause of the reloads and fixing any underlying issues in your test logic.

@rcollette
Copy link

rcollette commented Oct 8, 2024

I've hit this with Chrome 129 as well.

It only seems to be happening to me when running in headless mode so I have not been able to debug what is triggering window.onunload.

It seems to happen after all tests have run. I created a simple fdescribe test with an expect(true).toBeTrue() it block, and the issue still happens.

I suspect this has something to do with Chrome's "new" headless mode. Trying to see if that was the case, I tried setting headless=old but Karma-Chrome-Launch seems to not allow that.

    browsers: ["ChromeHeadless"],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: "ChromeHeadless",
        flags: [
          "--no-sandbox", // required to run without privileges in docker
          "--user-data-dir=/tmp/chrome-test-profile",
          "--disable-web-security",
          "--headless=old",
        ],
      },
    },

It seems to overwrite the headless option

08 10 2024 19:25:09.448:DEBUG [launcher]: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/var/folders/xr/4wd3v1l5547059_2kptbhfr80000gq/T/karma-93895891 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications --no-sandbox --user-data-dir=/tmp/chrome-test-profile --disable-web-security http://localhost:9877/?id=93895891 --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222

The issue does not happen when running with WebStorm

/Users/Richard.Collette/.nvm/versions/node/v20.15.1/bin/node /../myProjectDir/node_modules/@angular/cli/bin/ng test client --karma-config /Users/Richard.Collette/Applications/WebStorm.app/Contents/plugins/karma/js_reporter/karma-intellij/lib/intellij.conf.js --source-map

and it doesn't happen when I run in normal Chrome mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants