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

superagent not working as expected with CHROME #1390

Closed
palakdesai7 opened this issue Jul 5, 2018 · 6 comments
Closed

superagent not working as expected with CHROME #1390

palakdesai7 opened this issue Jul 5, 2018 · 6 comments

Comments

@palakdesai7
Copy link

palakdesai7 commented Jul 5, 2018

I am trying to print response from a API. very simple. Works fine when I run below script with Firefox.

code is something like this:

it('Verify "First Name" from api and profile page are same', function() {
     //Do initial login
       request
        .post("api url)
        .send({email:"test@test.com", password:"tester"})
        .set('Accept', 'application/json')
        .end(function(err,res){
          console.log(res.body); 
        });
        
    });

Any one facing issues with chrome and superagent.

Thanks

@kornelski
Copy link
Contributor

kornelski commented Jul 5, 2018

In general, we do not have any known problems with Chrome. 100% of our 198 tests pass in Chrome.

The code looks like from a test, not from actual superagent use. As it stands, this test is meaingless — it has no assertion, and doesn't even wait for the result.

Also you haven't provided any specific information about how chrome fails, what was expected and acutal result, and relevant information such as http headers from the client and the server.

@palakdesai7
Copy link
Author

@kornelski This test is an example. And as mentioned, I don't want to assert or do anything. Just want to print response. Test passes with no errors when browser is chrome. And superagent can be use in multiple ways. So here I want to use it to print response from api mentioned in post. Plus end function will wait till console.log is executed so no additional waiting is required.

Thanks

@kornelski
Copy link
Contributor

kornelski commented Jul 6, 2018

So for purpose of printing the code looks fine. I can't help you without specific description of what doesn't work, what should work, and what HTTP headers superagent has sent and received (from Chrome's network inspector or tcp dump).

@jonathansamines
Copy link

@palakdesai7 From your test seems like it is not waiting for the response (super agent is completely async). If your are using mocha, you can return the whole expression as mocha is promise-aware and superagent returns promises.

@palakdesai7
Copy link
Author

@jonathansamines Thanks I will try that.

@niftylettuce
Copy link
Collaborator

v5.0.0 was just released to NPM and an updated README is now available here on GitHub (see https://github.com/visionmedia/superagent#superagent).

What's new

  • Browser version is now only 19KB (that's 60% in file size savings from v4.x which was 48KB)!
  • Codebase refactored using xo, prettier, remark, and more
  • Browser compatibility linting via eslint-plugin-compat
  • Browserslist integration (current targets are > 1%, last 2 versions, ie 9)

How to install

npm install superagent@latest

Or if you're using yarn:

yarn add superagent@latest

Polyfills

Please see the Required Browser Features section in the README if you plan to support IE 9 and/or IE 10 and use superagent.

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

4 participants