I have an automated test setup written in javascript using jasmine and executing tests in parallel. Tests are executed using the following command:
protractor-flake --max-attempts=2 -- ./config/configfile.js --suite $SUITE "$@";
Inside the config file we set up all jasmine reporters, lists of all the test suites but also other prerequisites such as a class providing information about all the different feature flags that are on or off depending on the environment. The feature flags are fetched using an api call which happens in a method in configfile.js just before the tests are executed. I have tried creating a singleton and return the same instance but either i am doing something wrong or every new thread/process will create a new instance even if it's a singleton. Bellow is a simplified version of the singleton class.
class FeatureFlagConfiguration {
async getFlags() {
if (FeatureFlagConfiguration.instance === undefined) {
const client = new Client();
this.flags = await client.getFlags();
this.moreInfo = await client.getMoreInfo();
FeatureFlagConfiguration.instance = this;
Object.freeze(FeatureFlagConfiguration.instance);
}
}
evaluateFlags() {
...
}
isFeatureFlagEnabled() {
...
}
}
module.exports = new FeatureFlagConfiguration();