import uuid from 'uuid/v4'
export default function getTestIDs() {
if (process.env.NODE_ENV !== 'test') return {}
let ids = new Map()
let proxy = new Proxy({}, {
get: function(obj, prop) {
if (ids.has(prop) === false) {
ids.set(prop, uuid())
}
return ids.get(prop)
}
})
return proxy
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter