Choose specific variant when required
In our workplace we use visual diffing tools on snapshots as part of our regression testing.
When taking snapshots for our diffs it would be useful if we could specify a variant by name to keep our visual diffs consistent while a/b testing.
It looks like this is almost possible looking at the API docs, please let me know if this is possible.
It's possible to keep it consistent by setting the random or the get prop. For example:
function random() {
if (TESTING) {
return 0
}
return Math.random()
}
Hey, thanks for getting back to me.
This almost works as I want. Once a user's variant has been set (i.e. they already have a cookie set) I want that to be used. I just want to override in that specific instance.
You can also modify the get prop.
<Experiment get={(key) => {
if (cookie.get(key)) {
return cookie.get(key)
}
return "variant"
}} />