Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

fix: flakiness integ setup #727

Merged
merged 2 commits into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions main/integration-tests/support/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

const _ = require('lodash');
const jwtDecode = require('jwt-decode');
const { retry } = require('@aws-ee/base-services/lib/helpers/utils');

const Settings = require('./utils/settings');
const { getIdToken } = require('./utils/id-token');
Expand Down Expand Up @@ -261,10 +262,17 @@ class Setup {
* Use this function to gain access to a setup instance that is initialized and ready to be used.
*/
async function runSetup() {
const setupInstance = new Setup();
await setupInstance.init();
const tryCreateSetup = async () => {
const setupInstance = new Setup();
await setupInstance.init();

return setupInstance;
if (!setupInstance) throw Error('Setup instance did not initialize');
return setupInstance;
};

// Retry 3 times using an exponential interval
const setup = await retry(tryCreateSetup, 3);
return setup;
}

module.exports = { runSetup };