Skip to content

Instantly share code, notes, and snippets.

@javierfernandes
Created August 17, 2020 13:49
Show Gist options
  • Select an option

  • Save javierfernandes/ba81c9ef1323d30c2a1edbcb7c3f2457 to your computer and use it in GitHub Desktop.

Select an option

Save javierfernandes/ba81c9ef1323d30c2a1edbcb7c3f2457 to your computer and use it in GitHub Desktop.
Higher-order function to create a custom "describe" function keeping the .only/.skip functionality
const internalDescribe = (describeFn, bodyCaller) => (title, body) =>
describeFn(title, () => bodyCaller(body))
const createCustomDescribe = bodyCaller => {
const customDescribe = internalDescribe(describe, bodyCaller)
customDescribe.only = internalDescribe(describe.only, bodyCaller)
customDescribe.skip = internalDescribe(describe.skip, bodyCaller)
return customDescribe
}
export default createCustomDescribe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment