Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose specific variant when required #6

Open
laytong opened this issue Jul 7, 2016 · 3 comments
Open

Choose specific variant when required #6

laytong opened this issue Jul 7, 2016 · 3 comments

Comments

@laytong
Copy link

laytong commented Jul 7, 2016

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.

@olahol
Copy link
Owner

olahol commented Jul 7, 2016

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()
}

@laytong
Copy link
Author

laytong commented Jul 7, 2016

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.

@olahol
Copy link
Owner

olahol commented Jul 13, 2016

You can also modify the get prop.

<Experiment get={(key) => {
   if (cookie.get(key)) {
      return cookie.get(key)
   }

   return "variant"
}} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants