Helper function to replace placeholders in text
/
function replacePlaceHolder(string) {
for (const [key, value] of Object.entries(placeHolders)) {
string = string.replace(new RegExp(key, 'g'), value);
}
return string;
}
/**
Helper function to prepare URL by replacing placeholders and trimming slashes
/
function prepareUrl(url) {
return replacePlaceHolder(url).replace(/^\/+/, '');
}
/**
Helper function to get nested property from object using dot notation.
/
function getNestedProperty(obj, path) {
return path.split('.').reduce((current, prop) => {
return current && current[prop] !== undefined ? current[prop] : undefined;
}, obj);
}
/**
Adds Basic Authentication header to the next request.
Step pattern
Given (?:I am|we are) authenticating as "([^"]*)" with "([^"]*)" passwordExamples
Example #1
Given I am authenticating as "admin" with "password123" passwordExample #2
Given we are authenticating as "user@example.com" with "secret" passwordExample #3
Given I am authenticating as "api-user" with "pass!word" passwordExample #4
Given we are authenticating as "reader" with "readonly" password