Skip to content

Instantly share code, notes, and snippets.

@carmouche
Created May 15, 2020 06:23
Show Gist options
  • Save carmouche/1233b22e897959758641ce5acf0b85e1 to your computer and use it in GitHub Desktop.
Save carmouche/1233b22e897959758641ce5acf0b85e1 to your computer and use it in GitHub Desktop.
Quickly mock array of objects with unique id using lodash
import {times, random} from 'lodash';
const mockContext = {
property: times(10, i => ({
id: (i + 1).toString(),
// get randomized boolean values
isTruthy: !!random(0, 1)
}))
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment