-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Bug]: Jest does not support jquery ajax function with jsonp dataType #12611
Comments
Set `testEnvironmentOptions.resources="usable"By default, jsdom environment doesn't allow downloading the external script using The jquery jsonp's implementation is like below: const element = document.createElement("script");
// src point to the real jsonp request
element.src = `https://httpbin.org/get?callback=jQuery36005282486042709105_1648514920763&_=1648514920764`;
document.head.appendChild(element); you can add the below config to "jest": {
"testEnvironmentOptions": {
"resources": "usable"
}
} httpbin.org doesn't support jsonp maybe?after I add
$ curl https://httpbin.org/get\?callback\=jQuery36005017521770598357_1648515914254\&_\=1648515914255
{
"args": {
"_": "1648515914255",
"callback": "jQuery36005017521770598357_1648515914254"
},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/7.77.0",
"X-Amzn-Trace-Id": "Root=1-62425d19-171ac9033b85b4cf0d624eb4"
},
"origin": "220.243.131.228",
"url": "https://httpbin.org/get?callback=jQuery36005017521770598357_1648515914254&_=1648515914255"
} why add
|
@337Gslime is spam. could you help to ban this user? @SimenB see also here: #12578 |
@F3n67u I can delete their comments, unfortunately I do not have the accesses to block their access. I suggest reporting (I've just done so) and GH will probably delete the user |
That said, thank you so much for jumping in and trying to help here! I do not think this is a bug, but rather a usage question (and if it is a bug, it's in JSDOM, and not in Jest), so I'll close this. |
@F3n67u Thanks a lot for your kind help. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
27.5.1
Steps to reproduce
If you change dataType to
json
, you will see:Expected behavior
I expect that
$.ajax
function return status 200.Actual behavior
I see a timeout statusText.
Additional context
No response
Environment
System: OS: macOS 10.15.7 CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz Binaries: Node: 17.7.2 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.5.2 - /usr/local/bin/npm npmPackages: jest: ^27.5.1 => 27.5.1
The text was updated successfully, but these errors were encountered: