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

test: Update got to the latest version and fill in missing coverage #1825

Merged
merged 23 commits into from Feb 11, 2020

Conversation

greenkeeper[bot]
Copy link
Contributor

@greenkeeper greenkeeper bot commented Dec 1, 2019

The devDependency got was updated from 9.6.0 to 10.0.0.

This version is not covered by your current version range.

If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.


Publisher: sindresorhus
License: MIT

Release Notes for v10.0.0

We're excited to announce Got 10! 🎉 This release has been in the works for almost a year and has been a major undertaking. Got was fully rewritten in TypeScript, which helped us catch many bugs and will give us more confidence in the codebase going forward. Got is now faster and much more stable. We also fixed a huge amount of bugs. Big thanks to everyone that helped make this release possible. 🙌


If you find Got useful, you might want to sponsor the Got maintainers.

Note: Some HTTP agents like https-proxy-agent and agentkeepalive are not compatible with Node.js 10 and hence not compatible with Got as Got takes advantage of some Node.js 10-only APIs.

Breaking

  • Require Node.js 10 633651f
    • Why: This is so that we can use stream.pipeline for more reliable stream handling. Node.js 8 will be out of LTS at the end of this month anyway.
  • Remove support for protocol-less URLs in the url argument 92bc808
    • Why: To reduce ambiguity. It was not clear from just reading the code what it would default to.
    • Migrate:
- got('sindresorhus.com');
+ got('https://sindresorhus.com');
  • Rename the query option to searchParams and make it stricter b223663 5376216 518f0f5
    • Why: To get closer to the window.fetch naming in the browser.
    • Migrate:
- got(…, {query: …});
+ got(…, {searchParams: …});
  • Replace the baseUrl option with prefixUrl (#829) 0d534ed
    • Note: We also made it stricter to reduce ambiguity. The Got url argument now cannot be prefixed with a slash when this option is used.
    • Why: We renamed it to make it clear that it doesn't do any URL resolution.
    • Migrate:
- got('/foo', {baseUrl: 'https://x.com'});
+ got('foo', {prefixUrl: 'https://x.com'});
  • Change the json option to accept an object instead of a boolean and to only be responsible for the request, not the response (#704) a6a7d5a
    • Note: You now set the request body in this option instead of the body option when you want to send JSON. This option also no longer sets the response type to JSON. You either call the .json() method or specify the responseType option for that.
    • Why: Many people were confused how {json: true} worked and they also complained that they could not set the request/response type individually.
    • Migrate:
- got(url, {body: {x: true}, json: true});
+ got.post(url, {json: {x: true}}).json();
  • Use the responseType option instead of encoding to get a Buffer (#940) 6cc3d9f
    • Why: Previously, you would pass {encoding: null} to get a Buffer, but this was confusing. You now use {responseType: 'buffer'} instead.
    • Tip: You can also use got(…).buffer();.
    • Migrate:
- got(…, {encoding: null});
+ got(…, {responseType: 'buffer'});
  • Don't infer POST automatically when specifying body (#756) e367bdb
    • Why: We're trying to reduce the amount of magic behavior.
    • Migrate:
- got(…, {body: 'foo'});
+ got.post(…, {body: 'foo'});
  • The retries.retry option was split into retries.limit and retries.calculateDelay b15ce1d
    • Migrate:
 got(…, {
 	retry: {
-		retries: 2
+		limit: 2
 	}
 });
 got(…, {
 	retry: {
-		retries: iteration => iteration < 2
+		calculateDelay: ({attemptCount}) => attemptCount < 2
 	}
 });
 got(…, {
 	headers: {
-		'user-agent': null
+		'user-agent': undefined
 	}
 });
  • Rename the Promise API property .fromCache to .isFromCache (#768) b5e443b
  • Rename the stream option to isStream 518f0f5
    • Why: To make it clearer that it's a boolean and that it doesn't expect a stream to be passed in.
    • Migrate:
- got(…, {stream: true});
+ got(…, {isStream: true});
  • Don't include the Got version in the default user-agent header (#911) 95bed1e
    • got/9.6.0 (https://github.com/sindresorhus/got)got (https://github.com/sindresorhus/got)
    • Why: Importing package.json to get the version caused a lot of problems. And you should ideally set your own user-agent header anyway.
  • Remove got.create() 518f0f5
    • You can achieve the same thing with got.extend() now.
  • Remove got.mergeInstances() 518f0f5
    • Use gotInstance.extend(...gotInstances) instead.
  • Move top-level error properties into an .options and .response property (#773) 6eaa81b
    • Migrate:
- error.gotOptions
+ error.options

- error.headers
+ error.response.headers

- error.statusCode
+ error.response.statusCode

- error.statusMessage
+ error.response.statusMessage

- error.body
+ error.response.body

- error.redirectUrls
+ error.response.redirectUrls

- error.host
+ error.options.host

- error.hostname
+ error.options.hostname

- error.method
+ error.options.method

- error.protocol
+ error.options.protocol

- error.url
+ error.options.url

- error.path
+ error.options.path

  • Custom instance creation was simplified (#707) 8eaef94
    • Note: got.mergeInstances(...instances) is deprecated. Use instanceA.extend(instanceB) instead.
    • Migrate:
# Merging instances
- got.mergeInstances(instanceA, instanceB, instanceC, …);
+ instanceA.extend(instanceB, instanceC, …);

# Merging options
- instanceA.extend(optionsB).extend(optionsC).extend(…);
+ instanceA.extend(optionsB, optionsC, …);

# Merging instances and options
- got.mergeInstances(instanceA.extend(optionsB), instanceC);
+ instanceA.extend(optionsB, instanceC, …);

# Extending handlers
- got.mergeInstances(instanceA, got.create({handler: handlerB}));
+ instanceA.extend({handlers: [handlerB]});

Enhancements

Fixes

  • Fix parsing response when using afterResponse hook (#775) e2054cd
  • Fix port not being reset on redirect (#729) ada5861
  • Fix the retry functionality (#787) 0501e00
  • Fix default retry option value when specifying a number (#809) 9c04a7c
  • Correctly handle promise- and stream-specific errors in the beforeError hook 134c9b7
  • Don't throw on early lookups 4faf5c7
  • Fix Node.js 13 compatibility (#915) b0dfc95
  • Fix memory leak when using cache feature (#792) 518f0f5
  • Don't throw on 204 No Content when parsing response (#925) 518f0f5
  • When redirect fails, don't retry from scratch (#930) 518f0f5
  • Retrying inside afterResponse hook should trigger beforeRetry hook (#918) 518f0f5
  • Fix a bug that sometimes caused the Node.js process to hang 518f0f5
  • Fix a bug where cookies weren't reset on redirect between two different sites 518f0f5
  • Make the progress events not be based on internal Node.js properties cd11a50

Docs

  • Clarify retry behavior 5e6782a
  • Clarify prefixUrl behavior (#943) f008bc9
  • Document that retry option doesn't work with streams 9088866
  • Encourage using Stream.pipeline() when using the stream API 06afb27
  • Add instructions for global-agent (#822) ca8c560
  • Mention the TimeoutError.timings property 8fa18f4
  • Mention how to abort the request using hooks 96ea75f

All commits

v9.6.0...v10.0.0

Commits

The new version differs by 163 commits.

  • abdfee2 10.0.0
  • aae7b89 Improve readme
  • 71b8452 Improve types (#946)
  • f008bc9 Clarify prefixUrl behavior (#943)
  • d968e49 Upgrade dependencies
  • b82358f Add methodRewriting option (#942)
  • 966e7ff 10.0.0-beta.2
  • c537dee Make TypeScript types conforms to strict mode (#928)
  • d9a3273 Clarify retry behavior (#944)
  • 6cc3d9f Use responseType instead of options.encoding to get a Buffer (#940)
  • 3acdb69 Update a comment
  • d0f2dfd Mention that progress.total can be undefined
  • 8874a45 Preserve stacktrace when wrapping errors (#935)
  • b7a356a Fix .json() usage in readme.md
  • 2c5d0c0 Follow-up to cd11a5092972c16e5295f4d13dee20c228dcb19c

There are 163 commits in total.

See the full diff


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper bot 🌴

greenkeeper bot added a commit that referenced this pull request Dec 1, 2019
@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Dec 1, 2019

  • The devDependency got was updated from 9.6.0 to 10.0.1.

Update to this version instead 🚀

Release Notes for v10.0.1
  • Fix using the json option with got.stream.post 2ec5c4d

v10.0.0...v10.0.1

Commits

The new version differs by 4 commits.

See the full diff

greenkeeper bot added a commit that referenced this pull request Dec 7, 2019
@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Dec 7, 2019

  • The devDependency got was updated from 9.6.0 to 10.0.2.

Update to this version instead 🚀

greenkeeper bot added a commit that referenced this pull request Dec 9, 2019
@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Dec 9, 2019

  • The devDependency got was updated from 9.6.0 to 10.0.3.

Update to this version instead 🚀

@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Dec 12, 2019

  • The devDependency got was updated from 9.6.0 to 10.0.4.

Update to this version instead 🚀

greenkeeper bot added a commit that referenced this pull request Dec 12, 2019
greenkeeper bot added a commit that referenced this pull request Dec 19, 2019
@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Dec 19, 2019

  • The devDependency got was updated from 9.6.0 to 10.1.0.

Update to this version instead 🚀

greenkeeper bot added a commit that referenced this pull request Dec 23, 2019
@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Dec 23, 2019

  • The devDependency got was updated from 9.6.0 to 10.2.0.

Update to this version instead 🚀

greenkeeper bot added a commit that referenced this pull request Jan 1, 2020
@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Jan 1, 2020

  • The devDependency got was updated from 9.6.0 to 10.2.1.

Update to this version instead 🚀

@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Jan 11, 2020

  • The devDependency got was updated from 9.6.0 to 10.2.2.

Update to this version instead 🚀

greenkeeper bot added a commit that referenced this pull request Jan 11, 2020
greenkeeper bot added a commit that referenced this pull request Jan 24, 2020
@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Jan 24, 2020

  • The devDependency got was updated from 9.6.0 to 10.3.0.

Update to this version instead 🚀

@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Jan 31, 2020

  • The devDependency got was updated from 9.6.0 to 10.4.0.

Update to this version instead 🚀

@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Feb 6, 2020

  • The devDependency got was updated from 9.6.0 to 10.5.0.

Update to this version instead 🚀

greenkeeper bot added a commit that referenced this pull request Feb 6, 2020
@greenkeeper
Copy link
Contributor Author

greenkeeper bot commented Feb 7, 2020

  • The devDependency got was updated from 9.6.0 to 10.5.1.

Update to this version instead 🚀

greenkeeper bot added a commit that referenced this pull request Feb 7, 2020
greenkeeper bot added a commit that referenced this pull request Feb 7, 2020
@paulmelnikow
Copy link
Member

Beta, since Got 10 requires Node 10. Though the complexity of pieces like this is part of why I want this branch to be really short lived; see #1896.

@mastermatt
Copy link
Member

Right, I forgot Got dropped 8.x with their 10.x.

@paulmelnikow
Copy link
Member

There is one weird failure left in here after the changes I pushed, in test_allow_unmocked_https. @mastermatt Mind taking a look at it?

…0.0.0

# Conflicts:
#	tests/test_allow_unmocked.js
#	tests/test_allow_unmocked_https.js
There was a subtle, and I think unnecessary, change in Got 10.x where
using `prefixUrl` means the input, when making a request, can no longer
have a leading slash.
The prefix value can optionally have a trailing slash.
https://github.com/sindresorhus/got#prefixurl
@mastermatt
Copy link
Member

I think I've fixed it, but now there are two lines not being covered only on Node 12, windows-latest. 😕

@paulmelnikow
Copy link
Member

Odd, I'll take a look tomorrow.

@paulmelnikow
Copy link
Member

I guess it was transient?

paulmelnikow and others added 2 commits February 11, 2020 01:45
# Conflicts:
#	tests/test_allow_unmocked.js
#	tests/test_allow_unmocked_https.js
@paulmelnikow paulmelnikow changed the title Update got to the latest version 🚀 test: Update got to the latest version and fill in missing coverage Feb 11, 2020
@paulmelnikow
Copy link
Member

@mastermatt Good to merge?

Copy link
Member

@mastermatt mastermatt left a comment

Choose a reason for hiding this comment

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

:shipit:

@paulmelnikow paulmelnikow merged commit a7ffd7a into beta Feb 11, 2020
@paulmelnikow paulmelnikow deleted the greenkeeper/got-10.0.0 branch February 11, 2020 22:10
mastermatt added a commit to mastermatt/nock that referenced this pull request Feb 12, 2020
…ock#1825)

* chore(package): update got to version 10.0.0

* chore(package): update lockfile package-lock.json

* Bump got again and run npm install

* query -> searchParams

* encoding -> responseType

* `{body: …}` no longer implies `.post()`

* auth -> username + password

* query -> searchParams

* Error now has a `response` property

* Couple other fixes

* Restore 100% coverage

* Update lockfile

* refactor(test): use Mocha DSL for allow unmocked (nock#1894)

* refactor(test): use Mocha DSL for allow unmocked

* Fix format

* baseUrl -> prefixUrl

* Update json’s for breaking changes

* update usage of prefixUrl.

There was a subtle, and I think unnecessary, change in Got 10.x where
using `prefixUrl` means the input, when making a request, can no longer
have a leading slash.
The prefix value can optionally have a trailing slash.
https://github.com/sindresorhus/got#prefixurl

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: Matt R. Wilson <github@mattw.co>
paulmelnikow added a commit that referenced this pull request Feb 13, 2020
…1825)

* chore(package): update got to version 10.0.0

* chore(package): update lockfile package-lock.json

* Bump got again and run npm install

* query -> searchParams

* encoding -> responseType

* `{body: …}` no longer implies `.post()`

* auth -> username + password

* query -> searchParams

* Error now has a `response` property

* Couple other fixes

* Restore 100% coverage

* Update lockfile

* refactor(test): use Mocha DSL for allow unmocked (#1894)

* refactor(test): use Mocha DSL for allow unmocked

* Fix format

* baseUrl -> prefixUrl

* Update json’s for breaking changes

* update usage of prefixUrl.

There was a subtle, and I think unnecessary, change in Got 10.x where
using `prefixUrl` means the input, when making a request, can no longer
have a leading slash.
The prefix value can optionally have a trailing slash.
https://github.com/sindresorhus/got#prefixurl

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: Matt R. Wilson <github@mattw.co>
@github-actions
Copy link

🎉 This PR is included in version 11.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

gr2m pushed a commit that referenced this pull request Feb 16, 2020
…1825)

* chore(package): update got to version 10.0.0

* chore(package): update lockfile package-lock.json

* Bump got again and run npm install

* query -> searchParams

* encoding -> responseType

* `{body: …}` no longer implies `.post()`

* auth -> username + password

* query -> searchParams

* Error now has a `response` property

* Couple other fixes

* Restore 100% coverage

* Update lockfile

* refactor(test): use Mocha DSL for allow unmocked (#1894)

* refactor(test): use Mocha DSL for allow unmocked

* Fix format

* baseUrl -> prefixUrl

* Update json’s for breaking changes

* update usage of prefixUrl.

There was a subtle, and I think unnecessary, change in Got 10.x where
using `prefixUrl` means the input, when making a request, can no longer
have a leading slash.
The prefix value can optionally have a trailing slash.
https://github.com/sindresorhus/got#prefixurl

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: Matt R. Wilson <github@mattw.co>
gr2m pushed a commit that referenced this pull request Feb 16, 2020
…1825)

* chore(package): update got to version 10.0.0

* chore(package): update lockfile package-lock.json

* Bump got again and run npm install

* query -> searchParams

* encoding -> responseType

* `{body: …}` no longer implies `.post()`

* auth -> username + password

* query -> searchParams

* Error now has a `response` property

* Couple other fixes

* Restore 100% coverage

* Update lockfile

* refactor(test): use Mocha DSL for allow unmocked (#1894)

* refactor(test): use Mocha DSL for allow unmocked

* Fix format

* baseUrl -> prefixUrl

* Update json’s for breaking changes

* update usage of prefixUrl.

There was a subtle, and I think unnecessary, change in Got 10.x where
using `prefixUrl` means the input, when making a request, can no longer
have a leading slash.
The prefix value can optionally have a trailing slash.
https://github.com/sindresorhus/got#prefixurl

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: Matt R. Wilson <github@mattw.co>
gr2m pushed a commit that referenced this pull request Feb 16, 2020
…1825)

* chore(package): update got to version 10.0.0

* chore(package): update lockfile package-lock.json

* Bump got again and run npm install

* query -> searchParams

* encoding -> responseType

* `{body: …}` no longer implies `.post()`

* auth -> username + password

* query -> searchParams

* Error now has a `response` property

* Couple other fixes

* Restore 100% coverage

* Update lockfile

* refactor(test): use Mocha DSL for allow unmocked (#1894)

* refactor(test): use Mocha DSL for allow unmocked

* Fix format

* baseUrl -> prefixUrl

* Update json’s for breaking changes

* update usage of prefixUrl.

There was a subtle, and I think unnecessary, change in Got 10.x where
using `prefixUrl` means the input, when making a request, can no longer
have a leading slash.
The prefix value can optionally have a trailing slash.
https://github.com/sindresorhus/got#prefixurl

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: Matt R. Wilson <github@mattw.co>
gr2m pushed a commit that referenced this pull request Feb 16, 2020
…1825)

* chore(package): update got to version 10.0.0

* chore(package): update lockfile package-lock.json

* Bump got again and run npm install

* query -> searchParams

* encoding -> responseType

* `{body: …}` no longer implies `.post()`

* auth -> username + password

* query -> searchParams

* Error now has a `response` property

* Couple other fixes

* Restore 100% coverage

* Update lockfile

* refactor(test): use Mocha DSL for allow unmocked (#1894)

* refactor(test): use Mocha DSL for allow unmocked

* Fix format

* baseUrl -> prefixUrl

* Update json’s for breaking changes

* update usage of prefixUrl.

There was a subtle, and I think unnecessary, change in Got 10.x where
using `prefixUrl` means the input, when making a request, can no longer
have a leading slash.
The prefix value can optionally have a trailing slash.
https://github.com/sindresorhus/got#prefixurl

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: Matt R. Wilson <github@mattw.co>
gr2m pushed a commit that referenced this pull request Feb 16, 2020
…1825)

* chore(package): update got to version 10.0.0

* chore(package): update lockfile package-lock.json

* Bump got again and run npm install

* query -> searchParams

* encoding -> responseType

* `{body: …}` no longer implies `.post()`

* auth -> username + password

* query -> searchParams

* Error now has a `response` property

* Couple other fixes

* Restore 100% coverage

* Update lockfile

* refactor(test): use Mocha DSL for allow unmocked (#1894)

* refactor(test): use Mocha DSL for allow unmocked

* Fix format

* baseUrl -> prefixUrl

* Update json’s for breaking changes

* update usage of prefixUrl.

There was a subtle, and I think unnecessary, change in Got 10.x where
using `prefixUrl` means the input, when making a request, can no longer
have a leading slash.
The prefix value can optionally have a trailing slash.
https://github.com/sindresorhus/got#prefixurl

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: Matt R. Wilson <github@mattw.co>
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

2 participants