diff options
Diffstat (limited to 'spec/frontend/__helpers__/experimentation_helper.js')
-rw-r--r-- | spec/frontend/__helpers__/experimentation_helper.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/frontend/__helpers__/experimentation_helper.js b/spec/frontend/__helpers__/experimentation_helper.js index c08c25155e8..7a2ef61216a 100644 --- a/spec/frontend/__helpers__/experimentation_helper.js +++ b/spec/frontend/__helpers__/experimentation_helper.js @@ -12,3 +12,16 @@ export function withGonExperiment(experimentKey, value = true) { window.gon = origGon; }); } +// This helper is for specs that use `gitlab-experiment` utilities, which have a different schema that gets pushed via Gon compared to `Experimentation Module` +export function assignGitlabExperiment(experimentKey, variant) { + let origGon; + + beforeEach(() => { + origGon = window.gon; + window.gon = { experiment: { [experimentKey]: { variant } } }; + }); + + afterEach(() => { + window.gon = origGon; + }); +} |