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

Nock-1077 Remove airplane mode #1209

Merged
merged 18 commits into from
Jan 6, 2019

Conversation

jlilja
Copy link
Member

@jlilja jlilja commented Sep 7, 2018

Reference to #1077

Updated tests to use its own https server.

Query now also respects return value false. Why this happens during my rewrite I cannot understand or see. I think however passing functions in tests should be tested in file test_complex_querystrings.js.

Do we know the expected behavior of passing false in a function in query? If we do and it doesn't match the expected behavior of the second test, that should call for a new issue/pr.

if (queries && _.isFunction(queries) && queries() === false) {
this.queries = {}
return this
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a separate PR for the code change and only do tests? It's harder to review that way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Also, care to guess the expected behavior when function returns false in the query function? Just so I don't misinterpret the results I'm getting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t know 🤷‍♀️ Can you open a separate issue/PR for discussion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Once this test is fixed I'll work on it. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlilja Any time to work on this? :)

request(options, (error, response, body) => {
test.true((error === null), 'should be no error')
test.true(typeof body !== 'undefined', 'body should not be undefined')
test.true(body.length !== 0, 'body should not be empty')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is intended to fall through to the real server. Could you add assertions that match the body and/or status code to what the server returns?

@gr2m
Copy link
Member

gr2m commented Dec 16, 2018

@jlilja looook: #1209 let’s finish this up 🙌

@paulmelnikow paulmelnikow mentioned this pull request Dec 19, 2018
@gr2m
Copy link
Member

gr2m commented Dec 20, 2018

@jlilja mind if we finish this up? It's the last bit to get rid of the AIRPLANE mode and it’s starting to block

@paulmelnikow
Copy link
Member

@gr2m do you want to wrap this one up?

@gr2m
Copy link
Member

gr2m commented Jan 2, 2019

I’ll be busy until Jan 9th, I can look into it afterwards. Feel free to tackle it yourself if you like

@jlilja
Copy link
Member Author

jlilja commented Jan 3, 2019

Terribly sorry, I've been away for holidays! If you haven't already taken over this PR, I will fix this today. @paulmelnikow have you started working on this?

@paulmelnikow
Copy link
Member

Please do! 😁

We're targeting the beta branch now so probably best to start a new branch and manually pick over the changes. You'll want to set up Prettier to handle formatting as well (or run npm run prettier if you don't want to set it up).

@jlilja
Copy link
Member Author

jlilja commented Jan 3, 2019

Sweet! Been using prettier since before, so no problem. Will the beta branch be a big merge with all of the tests updated? Or is this a branch that'll stay for future changes as well?

@gr2m
Copy link
Member

gr2m commented Jan 3, 2019

We will eventually merge beta into master which will then automatically release the new breaking version. After that we probably make master the main branch again until we want to work with pre-releases again :)

@paulmelnikow
Copy link
Member

@jlilja How'd you make out?

@jlilja
Copy link
Member Author

jlilja commented Jan 5, 2019

I've made a fix for my code to do the check you asked about. However I couldn't make it work with the request package. I instead tried to do the same logic however with axios - and with axios it works just as I want.

Now this probably raises another question as to why axios works and request fails.

Depending on what you think I can probably merge it into beta or I'll go back to try and troubleshoot why it isn't working with request.

@jlilja
Copy link
Member Author

jlilja commented Jan 5, 2019

I just saw that you're converting to the got package in other commits. If I switch from axios to got (and fix that linting travis notices), are we good? :)

@jlilja
Copy link
Member Author

jlilja commented Jan 6, 2019

I've been applying linting fixes from the rules in the beta branch but it seems to still be complaining about my code in Travis, however not locally. Could someone have a look?

@paulmelnikow
Copy link
Member

paulmelnikow commented Jan 6, 2019

One thing you could try is deleting node_modules and running npm install again. We have a lockfile now. Also, merge beta into this branch (or rebase this onto beta) if you haven't already.

Oh! I see that's the problem. Some updates to the lint config made in the beta branch are necessary for the tests to pass.

@paulmelnikow paulmelnikow changed the base branch from master to beta January 6, 2019 10:20
const { body } = await got(`${url}/otherpath`)
t.true(JSON.parse(body).status === 'default')
} catch (error) {
console.warn(error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these try/catch should be removed so those conditions will just throw. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is probably better. Didn't think of the error handling while in a test.

console.warn(error)
}

t.end()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.end() will happen automatically on tests with async.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know that. I'll fix it.

nock('https://www.google.com/', { allowUnmocked: true })
.get('/pathneverhit')
.reply(200, { foo: 'bar' })
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done with { rejectUnauthorized: true } passed to got instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This i so confusing. While trying to change, the test appears to be working without the tls boolean. Could have been fixed I set the port explicitly to 3000 instead of letting https.createServer assign a random port. I'll push and see what Travis says as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Stupid me. Was changing in the wrong repo and branch...

@jlilja
Copy link
Member Author

jlilja commented Jan 6, 2019

I'm still a bit confused if I've merged/rebased correctly. Let me know if I can do anything differently from here on.

@paulmelnikow
Copy link
Member

It looks good! In the future if you start with the beta branch things should be easier. 😁

@paulmelnikow paulmelnikow merged commit 26954a7 into nock:beta Jan 6, 2019
@gr2m
Copy link
Member

gr2m commented Jan 6, 2019

OMG! Did we just hit our first big milestone?! A celebration is in order /cc @RichardLitt

I see #1367 is the last bit to close #1077 :)

@jlilja
Copy link
Member Author

jlilja commented Jan 6, 2019

This is so exciting! This should be posted in #1268 😄

@RichardLitt
Copy link
Member

RichardLitt commented Jan 11, 2019

Woo! Well done, @jlilja!

@nockbot
Copy link
Collaborator

nockbot commented Jan 19, 2019

🎉 This PR is included in version 11.0.0-beta.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nockbot
Copy link
Collaborator

nockbot commented Aug 13, 2019

🎉 This PR is included in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants