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

[lib/test.js] Support URLs without leading slash #512

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

petermikitsh
Copy link

I hit a weird issue and a cryptic error message when using this library. Decided to fix to simplify its usage.

Test Code:

import app from '../../../app'; // a plain old express app
import request from 'supertest';

test('happy path: ', async () => {
  const agent = request.agent(app);
  const res = await agent
    .get('api/tenants/startauth');
});

Output:

  ● happy path: 

    connect ECONNREFUSED 0.0.0.0:80

       7 |   const agent = request.agent(app);
       8 |   const res = await agent
    >  9 |     .host('0.0.0.0')
         |                                         ^
      10 |     .get('api/tenants/startauth');
      11 |     

Adding a leading slash to my get call fixed the problem. But with additional logging, I noticed the serverAddress function returned the invalid URL http://127.0.0.1:57625api/tenants/startauth.

This PR allows for the leading slash to be optional, fixing the URL generation and makes the cryptic error go away -- a better experience for all users of this library.

@coveralls
Copy link

coveralls commented Sep 14, 2018

Pull Request Test Coverage Report for Build 334

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 97.297%

Totals Coverage Status
Change from base Build 330: 0.01%
Covered Lines: 137
Relevant Lines: 141

💛 - Coveralls

@rimiti
Copy link
Contributor

rimiti commented Mar 15, 2019

@gjohnson could you check it please? 🙏

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

Successfully merging this pull request may close these issues.

None yet

3 participants