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

Question: hammerhead.js:277 Uncaught (in promise) TypeError: Wa.global.location.toString is not a function #2716

Closed
nottoseethesun opened this issue Dec 10, 2021 · 4 comments

Comments

@nottoseethesun
Copy link

nottoseethesun commented Dec 10, 2021

What is your Scenario?

Not asserting that this is a bug: This is a question about observed TypeError in hammerhead.js, to get more info.

Scenario: Running a test that, prior to the test target system being changed to React from vanilla/jQuery js, worked.

What is the Current behavior?

The application test is failing due to a TypeError in hammerhead: The failing line is:

return e && Rt(e) ? Xl.get().referer : Wa.global.location.toString();

And the part that fails there is the call to toString.

(The line numbers are from a formatting, to be able to inspect)

hammerhead.js:277 Uncaught (in promise) TypeError: Wa.global.location.toString is not a function
    at re (hammerhead.js:277)
    at ke (hammerhead.js:384)
    at XMLHttpRequest.open (hammerhead.js:7543)
    at nt (6.11.0-20210204.js:2)
    at 6.11.0-20210204.js:2
    at new Promise (<anonymous>)
    at t.<anonymous> (6.11.0-20210204.js:2)
    at g (6.11.0-20210204.js:2)
    at Generator.l._invoke (6.11.0-20210204.js:2)
    at Generator.next (6.11.0-20210204.js:2)

This is in the top-level web browser window.

In the web app window, window is null and so is document.location. This indicates that the window has no browser context object.

Going back in the call stack, I see an http request, initiated by the web app being tested, going outbound to a url that is a 404.

Inspecting the TestCafe app test code in Chrome DevTools (nodejs debugging), I see that the issue happens before the test's requestHooks statement executes, and possibly, before all of the before statement has finished.

To simplify in this scenario, only one test is being run.

TestCafe runner options are as follows:

│     (index)      │                 Values                  │
├──────────────────┼─────────────────────────────────────────┤
│     nodeEnv      │                 'prod'                  │
│       port       │                  1337                   │
│   testProject    │                'foo-bar'                 │
│    testFilter    │               'foo-bar-bat'               │
│ testIgnoreFilter │                   ''                    │
│    debugMode     │                  false                  │
│   debugOnFail    │                  true                   │
│     headless     │                  false                  │
│    inspectBrk    │                'chrome'                 │
│ assertionTimeout │                  5000                   │
│ pageLoadTimeout  │                  3000                   │
│   concurrency    │                    1                    │
│ stopOnFirstFail  │                  false                  │
│  useCachedData   │                  false                  │
│      repeat      │                    1                    │
│   configCheck    │                  false                  │
│    appCommand    │                   ''                    │
│   testBrowser    │ 'chrome: --auto-open-devtools-for-tabs' 

What is the Expected behavior?

There should be no such TypeError as described, or at least, it should not fail the app test.

What is your public website URL? (or attach your complete example)

Please see this test case that should reproduce the exact same error: #2178

What is your TestCafe test code?

Cannot share

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. Start test
  2. Observe failed test

TestCafe version

1.16.0

Node.js version

v16.10.0

Command-line arguments

Started programmatically.

Browser name(s) and version(s)

Chrome 96

Platform(s) and version(s)

macOS Monterey

Other

No response

@github-actions
Copy link

Thank you for submitting this issue. We would love to assist you and diagnose it. However, we need a simple sample that we can easily run on our side in order to replicate the issue and research its cause. Without a sample, we are not able to figure out what's going on and why this issue occurs. Refer to this article to create the best example: How To: Create a Minimal Working Example When You Submit an Issue. We look forward to your response.

@nottoseethesun
Copy link
Author

Updated with a reference to the requested test case. I think what may be happening here is that the TestCafe iframe is getting removed from the dom during React's render loop.

@Farfurix
Copy link
Contributor

@nottoseethesun

Hello,

I reproduced the Uncaught TypeError: Wa.global.location.toString is not a function error with macOS and Windows in Chrome using the linked example. I'll close this issue as a duplicate and reopen the original one (#2178).

@nottoseethesun
Copy link
Author

Note: Also happens in same exact scenario with testcafe@1.17.1 (the latest as of this writing).

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

No branches or pull requests

4 participants