From de8304c4c11b174a17f88aad652658ab466fea29 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 30 Apr 2021 11:12:51 +0000 Subject: [PATCH 1/2] chore(deps): update dependency node-fetch to v2.6.1 --- package-lock.json | 18 +++++++++--------- package.json | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 03909e10a05..dc2557b552e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4913,9 +4913,9 @@ "integrity": "sha512-xdcqtQl1g3p/49kmcj7ZixPWOcNHA1tYNz+uN0PJEcgtN6zywK74aacTnd3eFGPuBpD7kK8vowmMRkUt6jHU/Q==" }, "@types/node-fetch": { - "version": "2.5.8", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.8.tgz", - "integrity": "sha512-fbjI6ja0N5ZA8TV53RUqzsKNkl9fv8Oj3T7zxW7FGv1GSH7gwJaNF8dzCjrqKaxKeUpTz4yT1DaJFq/omNpGfw==", + "version": "2.5.10", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.10.tgz", + "integrity": "sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==", "dev": true, "requires": { "@types/node": "*", @@ -4932,9 +4932,9 @@ } }, "form-data": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", - "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", "dev": true, "requires": { "asynckit": "^0.4.0", @@ -16669,9 +16669,9 @@ } }, "node-fetch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", - "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" }, "node-fetch-npm": { "version": "2.0.4", diff --git a/package.json b/package.json index 9c634955aca..a9181821e8e 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "@types/micro": "7.3.4", "@types/nock": "10.0.3", "@types/node": "8.10.65", - "@types/node-fetch": "2.5.8", + "@types/node-fetch": "2.5.10", "@types/qs": "6.9.6", "@types/qs-middleware": "1.0.1", "@types/request": "2.48.5", @@ -120,7 +120,7 @@ "memcached-mock": "0.1.0", "mock-req": "0.2.0", "nock": "10.0.6", - "node-fetch": "2.3.0", + "node-fetch": "2.6.1", "prettier": "2.1.2", "qs-middleware": "1.0.3", "request": "2.88.2", From df277620eb6f30ae4f218b651d8e5a08426dc5a4 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Fri, 30 Apr 2021 11:20:40 +0000 Subject: [PATCH 2/2] tests: Use `toString()` method to test Buffer contents As of `node-fetch@2.4.0`, its internal representation of `body` is now normalized to a `Buffer` during `Request` construction, and will always be returned as a `Buffer`, rather than having the `body` being either a String _or_ a Buffer. This defeated the way we were testing the `body` but shouldn't affect the actual `Response`'s `body`. Ref: https://github.com/node-fetch/node-fetch/commit/7d3293200a91a --- .../src/__tests__/RESTDataSource.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/apollo-datasource-rest/src/__tests__/RESTDataSource.test.ts b/packages/apollo-datasource-rest/src/__tests__/RESTDataSource.test.ts index 9eed76d5748..5efaecd2c2b 100644 --- a/packages/apollo-datasource-rest/src/__tests__/RESTDataSource.test.ts +++ b/packages/apollo-datasource-rest/src/__tests__/RESTDataSource.test.ts @@ -260,7 +260,7 @@ describe('RESTDataSource', () => { expect(fetch).toBeCalledTimes(1); expect(fetch.mock.calls[0][0].url).toEqual('https://api.example.com/foo'); - expect(fetch.mock.calls[0][0].body).toEqual( + expect(fetch.mock.calls[0][0].body.toString()).toEqual( JSON.stringify({ foo: 'bar' }), ); expect(fetch.mock.calls[0][0].headers.get('Content-Type')).toEqual( @@ -285,7 +285,7 @@ describe('RESTDataSource', () => { expect(fetch).toBeCalledTimes(1); expect(fetch.mock.calls[0][0].url).toEqual('https://api.example.com/foo'); - expect(fetch.mock.calls[0][0].body).toEqual( + expect(fetch.mock.calls[0][0].body.toString()).toEqual( JSON.stringify(['foo', 'bar']), ); expect(fetch.mock.calls[0][0].headers.get('Content-Type')).toEqual( @@ -321,7 +321,7 @@ describe('RESTDataSource', () => { expect(fetch).toBeCalledTimes(1); expect(fetch.mock.calls[0][0].url).toEqual('https://api.example.com/foo'); - expect(fetch.mock.calls[0][0].body).toEqual( + expect(fetch.mock.calls[0][0].body.toString()).toEqual( JSON.stringify({ foo: 'bar' }), ); expect(fetch.mock.calls[0][0].headers.get('Content-Type')).toEqual( @@ -349,7 +349,7 @@ describe('RESTDataSource', () => { expect(fetch).toBeCalledTimes(1); expect(fetch.mock.calls[0][0].url).toEqual('https://api.example.com/foo'); - expect(fetch.mock.calls[0][0].body).not.toEqual('{}'); + expect(fetch.mock.calls[0][0].body.toString()).not.toEqual('{}'); expect(fetch.mock.calls[0][0].headers.get('Content-Type')).not.toEqual( 'application/json', );