From d7d62352b827eaf8425bf314a357f1a42744239a Mon Sep 17 00:00:00 2001 From: Rebecca Meritz Date: Thu, 18 Jun 2020 12:28:15 -0700 Subject: [PATCH] Ensure fetch works in node 8 - Remove the use of finally. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally#Browser_compatibility - Increase timeouts because test became flakely otherwise --- lib/run_action.js | 4 ++-- test/find.test.js | 4 ++-- test/test_helpers.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/run_action.js b/lib/run_action.js index 90ac85ce..7905aebc 100644 --- a/lib/run_action.js +++ b/lib/run_action.js @@ -68,9 +68,9 @@ function runAction(base, method, path, queryParams, bodyData, callback, numAttem .catch(callback); } }) - .catch(callback) - .finally(function() { + .catch(function(error) { clearTimeout(timeout); + callback(error); }); } diff --git a/test/find.test.js b/test/find.test.js index 4ebdc011..6782f55f 100644 --- a/test/find.test.js +++ b/test/find.test.js @@ -7,7 +7,7 @@ describe('record retrival', function() { var testExpressApp; var teardownAsync; - beforeAll(function() { + beforeEach(function() { return testHelpers.getMockEnvironmentAsync().then(function(env) { airtable = env.airtable; testExpressApp = env.testExpressApp; @@ -15,7 +15,7 @@ describe('record retrival', function() { }); }); - afterAll(function() { + afterEach(function() { delete global.window; return teardownAsync(); }); diff --git a/test/test_helpers.js b/test/test_helpers.js index 4396ab1d..fdf43e72 100644 --- a/test/test_helpers.js +++ b/test/test_helpers.js @@ -143,7 +143,7 @@ function getMockEnvironmentAsync(options) { airtable: new Airtable({ apiKey: 'key123', endpointUrl: 'http://localhost:' + testServerPort, - requestTimeout: 100, + requestTimeout: 1000, }), teardownAsync: util.promisify(testServer.close.bind(testServer)), testExpressApp: app,