Nock: Remove AIRPLANE mode for testing - make all tests run offline

Created on 27 Feb 2018  ·  28Comments  ·  Source: nock/nock

41 tests are currently skipped when run with AIRPLANE=true. Most if not all of these tests depend on external websites, which means if they change their behavior or are temporarily down, our tests will fail.

Instead of depending on outside websites I suggest we spawn our own servers as we need them, it is simple enough.

See #1083 for an example pull request / change set.

I think these are all occurrences where we use the {skip: process.env.AIRPLANE} setting.

If you’d like to help out, great! Please do the following

  1. comment below which one of these (can be multiple) you want to work on
  2. create an issue with the list of occurrences you want to work on and reference this issue (#1077)
  3. Then update your comment below with a link to that issue, I’ll keep the "Available" list updated

Claimed / in progress

🤷‍♀️

Available

🤷‍♂️

Done

  • [x] [tests/test_https_allowunmocked.js#L9](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_https_allowunmocked.js#L9) @jlilja https://github.com/nock/nock/pull/1209
  • [x] [tests/test_https_allowunmocked.js#L27](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_https_allowunmocked.js#L27) @jlilja https://github.com/nock/nock/pull/1209
  • [x] [tests/test_recorder.js#L93](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L93) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L140](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L140) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L195](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L195) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L209](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L209) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L236](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L236) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L340](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L340) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L374](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L374) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L409](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L409) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L457](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L457) @paulmelnikow PR: #1283
  • [x] [tests/test_recorder.js#L502](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L502) #1281
  • [x] [tests/test_recorder.js#L555](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L555) #1281
  • [x] [tests/test_recorder.js#L586](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L586) #1281
  • [x] [tests/test_recorder.js#L621](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L621) #1281
  • [x] [tests/test_recorder.js#L656](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L656) #1281
  • [x] [tests/test_recorder.js#L689](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L689) #1281
  • [x] [tests/test_recorder.js#L710](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L710) #1281
  • [x] [tests/test_recorder.js#L62](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L62) #1279
  • [x] [tests/test_recorder.js#L852](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L852) #1280
  • [x] [tests/test_recorder.js#L733](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L733) #1280
  • [x] [tests/test_recorder.js#L796](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L796) #1280
  • [x] [tests/test_recorder.js#L824](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L824) #1280
  • [x] [tests/test_nock_off.js#L6](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_nock_off.js#L6) https://github.com/nock/nock/pull/1277 @gr2m
  • [x] [tests/test_recorder.js#L36](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_recorder.js#L36) https://github.com/nock/nock/pull/1278 @RichardLitt
  • [x] [tests/test_intercept.js#L2885](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_intercept.js#L2885)
  • [x] [tests/test_intercept.js#L2902](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_intercept.js#L2902)
  • [x] [tests/test_intercept.js#L2684](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_intercept.js#L2684)
  • [x] [tests/test_intercept.js#L2728](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_intercept.js#L2728)
  • [x] [tests/test_intercept.js#L2745](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_intercept.js#L2745)
  • [x] [tests/test_intercept.js#L3673](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_intercept.js#L3673)
  • [x] [tests/test_back.js#L154](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back.js#L154) – PR: #1082
  • [x] [Add "Do not copy" comment to all tests that still use "{skip: process.env.AIRPLANE}" setting](https://github.com/nock/nock/issues/1232)
  • [x] [tests/test_back.js#L137](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back.js#L137) – PR: #1083
  • [x] [tests/test_back.js#L188](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back.js#L188) - PR: #1087
  • [x] [tests/test_back.js#L235](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back.js#L235) - PR: #1088
  • [x] [tests/test_back.js#L261](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back.js#L261) - PR: #1090
  • [x] [tests/test_back.js#L313](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back.js#L313) – PR: #1093
  • [x] [tests/test_back_2.js#L31](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back_2.js#L31) - PR: #1097
  • [x] [tests/test_back_2.js#L53](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back_2.js#L53) - PR: #1097
  • [x] [tests/test_intercept.js#L2108](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_intercept.js#L2108) - PR: #1104
  • [x] [tests/test_intercept.js#L2658](https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_intercept.js#L2658) - PR: #1104
good first issue help wanted pinned released released on @beta

Most helpful comment

All 28 comments

@gr2m this looks quite extensive!
Claiming tests/test_back.js#L154 to begin with 🙂 . Would you recommend me to raise an issue too (like you did for your current WIP : tests/test_back.js#L137 ?)

yes please :)

Claiming tests/test_back.js#L188, tests/test_back.js#L235 and tests/test_back.js#L261 !

@gr2m ,
Why do I feel like this task is a perfect candidate to test GitHub projects? 😛

If you think that’ll help, feel free to use it :)

https://github.com/node-nock/nock/blob/055593abb036524ffff8f364f8effc91827a130f/tests/test_back.js#L261 is fixed in #1090 please remove it from wip. :)

cheers @anshumanv 👍 fixed it! Wanna try to work on one of the available ones?

Yes! I just forked, solving them one at a time. :)
Thanks @gr2m :smile:

Let us know which one you are working on so we don’t do the work twice :)

Taking out test_back_2.js tests this time!

Claiming tests in test_intercept.js

Hey @mbad0la wanna help finish this up? I’m busy this week but will have more time next week I hope. Would be great to get trough with it, tests are currently failing because another external host is not doing what it did in the past, time we remove dependency on that :)

I've been blocked on spinning up a local https server. I looked around a bit but didn't find any easy workarounds. Can you help me figure that out?

Ah yes, I did that recently for @ocotkit/rest.js: https://github.com/octokit/rest.js/blob/master/test/integration/agent-ca/agent-ca-test.js. I think I got that setup from https://github.com/request/request

Does that help?

I did give the above examples a look some time back, but didn't have much success with the tests here. I'll give this another go in a day or two and keep you posted on any updates.

sounds good :) If you get stuck, create a WIP pull request, we can take it from there. Thanks!

Claiming test_https_allowunmocked.js!

Thank you for helping out, Jonas!

I'm working on tests/test_intercept.js#L2684 now.

I’ll work on tests/test_nock_off.js#L6

I’ll work on tests/test_recorder.js#L62 next

I've got another half hour here. I'm on a train and my signal is a bit limited, though I'll work on tests/test_recorder.js#L852 and keep working my way back until time runs out.

I'm going to see if I can't knock off the rest of these.

:tada: This issue has been resolved in version 11.0.0-beta.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

:tada: This issue has been resolved in version 11.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robinbobbitt picture robinbobbitt  ·  5Comments

cristianszwarc picture cristianszwarc  ·  6Comments

borekb picture borekb  ·  7Comments

glockjt picture glockjt  ·  3Comments

gr2m picture gr2m  ·  6Comments