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

TypeError: Cannot use 'in' operator to search for 'withCredentials' in undefined #218

Open
rahulkelaskar opened this issue Jun 19, 2023 · 1 comment

Comments

@rahulkelaskar
Copy link

The library doesn't pass through Jest unit test. On debug it is observed that
NativeEventSource is undefined. Since the Jest runs on terminal NativeEventSource is undefined.
var R = NativeEventSource if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {

I've tried multiple ways, but couldn't find any solution.

I'm currently using
angular: 12.2.0
"jest": "^27.0.3",
"jest-junit": "^11.1.0",
"jest-preset-angular": "9.0.0",
"jest-zone-patch": "~0.0.10",

@Yaffle
Copy link
Owner

Yaffle commented Jun 19, 2023

NativeEventSource is not undefined so, otherwise the "in" is not executed because of the short-circuit evaluation and "NativeEventSource == undefined" check.
perhaps, you have NativeEventSource.prototype == undefined, which is weird. could you just do something to set it to non-undefined value? (or just do globalThis.EventSource = undefined)

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

2 participants