End to end test http requests - testing

What end-to-end testing JavaScript framework is best to test outgoing HTTP requests?
I want to test HTTP request's payloads as well.
I am considering Nightwatch.js, but so far I couldn't figure out if Nightwatch.js allows testing the HTTP request and its payload.
(I am not using AngularJS on my website.)

I would recommend using Puppeteer to test HTTP requests.
There is an entire request class built-in for when a request is issued by a page:
request.abort()
request.continue()
request.failure()
request.frame()
request.headers()
request.isNavigationRequest()
request.method()
request.postData()
request.redirectChain()
request.resourceType()
request.respond()
request.response()
request.url()
There is also a response class for when/if the response is received by the page for the request:
response.buffer()
response.fromCache()
response.fromServiceWorker()
response.headers()
response.json()
response.ok()
response.request()
response.securityDetails()
response.status()
response.text()
response.url()

or you can use request-promise lib and to be happy)

Related

Jmeter showing response code as 300 in response

I am working in a desktop application which contains API as well.
So when I try to hit the API using Jmeter with the local server name as localhost. I am getting the response as below
Response code:300
Response message:MULTIPLE CHOICES
Response data:
{"succeed": false, "error_message": "No data JSON received!"}
Even I tried with the Content-Type as application/json and multipart/form-data, but not worked.
Note: When I try to hit the same API using Postman, I got the 200 status.
If you're able to successfully execute the request using Postman you should be able to do this using JMeter as well. We cannot state what's wrong without seeing your Postman and JMeter configurations, just make sure that everything is the same:
request URL
request bosy
request headers
etc.
If you will send the same request - you will get the same response.
Be aware that you can just record the request from Postman using JMeter
Start JMeter's HTTP(S) Test Script Recorder
If you're using HTTPS protocol - import JMeter's certificate into Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Same HTTPS request works in Postman but gives 400 Bad Request in JMeter

I think I tried all the possible combinations of headers and body for my POST request in JMeter but is giving me 400 Bad Request saying that the languagePairID parameter from the body is invalid even tho it is exactly same as in Postman.
My headers:
And the request:
Meanwhile in Postman in works perfectly fine:
I tried checking and unchecking the multipart/form-data and browser-compatible headers, but nothing seems to help. I read that using Wireshark might be useful in such cases but I think for this one is not possible as it is HTTPS. I will be very grateful for any advice.
Uncheck "Use mutipart/form-data"
Remove everything from the "Body Data" tab
Switch to "Parameters" tab and put your parameters there:
Going forward be informed that you can easily convert your Postman script into JMeter:
Start JMeter's HTTP(S) Test Script Recorder
Import JMeter's certificate to Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Bad Request : 400, when generating bearer token for OAuth2.0

I have setup an api in jmeter which will generate the bearer token for OAuth 2.0. When checking the request body in view result tree listener, seems like jmeter is not parsing the -Client Secret key.
request making
View Result tree - Request body
Response - 400
Please try the below,
Tried it on postman, (working fine)
Now from JMeter, (working fine)
I guess you missed the checkboxes (URL Encode?) in the request parameters in the Jmeter section
HTTP Status 400 means "bad request", one of your request parameters is not correct, like URL or request data or request headers, cross check them with browser/postman
If you're able to successfully execute the request using Postman you can just record the request from Postman using JMeter's HTTP(S) Test Script Recorder
Start JMeter proxy server
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate appropriate HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Cypress.IO support for JSONP

I've been able to use the following successfully with XHR Requests:
cy.server();
cy.route('GET','**/foo').as('bar');
//trigger ui event that make xhr GET request
cy.wait('#bar');
//happily proceed...
However, if I apply the same logic above, but to a JSONP Network Request, then cy.wait(...) will eventually time out.
The application I am testing sends jsonp requests. Using cypress.io, I would like to register these requests with the intent of waiting for a response using something like cy.wait. Does cypress.io provide any support for jsonp requests?

How to pass form-data while calling API using Jmeter?

I want to make an API call using Jmeter.
In my API call, I'm sending a file with a request,
and I need to specify the file name as form-data.
e.g. when I call the same API from postman !
How do I, specify a filename when I make above call from Jmeter?
Jmeter call :
HTTP Request Sampler provides options to
set Use multipart/form-data for HTTP POST
send files with the request
See Performance testing: Upload and Download Scenarios with Apache JMeter guide for detailed explanations and configuration instructions.