{"action":"closed","issue":{"url":"https://api.github.com/repos/mjackson/expect/issues/166","repository_url":"https://api.github.com/repos/mjackson/expect","labels_url":"https://api.github.com/repos/mjackson/expect/issues/166/labels{/name}","comments_url":"https://api.github.com/repos/mjackson/expect/issues/166/comments","events_url":"https://api.github.com/repos/mjackson/expect/issues/166/events","html_url":"https://github.com/mjackson/expect/issues/166","id":184398027,"number":166,"title":"expect().inArray([42,21,3,7)","user":{"login":"asmodehn","id":221256,"avatar_url":"https://avatars.githubusercontent.com/u/221256?v=3","gravatar_id":"","url":"https://api.github.com/users/asmodehn","html_url":"https://github.com/asmodehn","followers_url":"https://api.github.com/users/asmodehn/followers","following_url":"https://api.github.com/users/asmodehn/following{/other_user}","gists_url":"https://api.github.com/users/asmodehn/gists{/gist_id}","starred_url":"https://api.github.com/users/asmodehn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmodehn/subscriptions","organizations_url":"https://api.github.com/users/asmodehn/orgs","repos_url":"https://api.github.com/users/asmodehn/repos","events_url":"https://api.github.com/users/asmodehn/events{/privacy}","received_events_url":"https://api.github.com/users/asmodehn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-21T04:41:05Z","updated_at":"2016-10-23T12:51:03Z","closed_at":"2016-10-23T12:51:03Z","body":"I just encountered a potential usecase that I don't think is currently covered by expect : \r\n\r\nI can run code that will randomly return something, like : \r\n```js\r\nvar myArray = ['A', 'B', 'C'];\r\nvar rand = myArray[Math.floor(Math.random() * myArray.length)];\r\n```\r\nThis can be because randomness in code, like this example, but also randomness in execution (more complex). For example, I may want to test concurrency patterns, like a mutex, and execute multiple functions concurrently (with [async](http://caolan.github.io/async/docs.html#parallel)). I do not know which function will succeed or fail, so I want to expect \"one in many\" possible value.\r\n\r\nSo something like : \r\n\r\n```js\r\nexpect(rand).toBeIn(['A', 'B', 'C']);  //rand can only be 'A', 'B' or 'C'.\r\n```\r\n"}}
{"actor":{"display_login":"asmodehn"}}