Skip to content

Instantly share code, notes, and snippets.

@scriptschat
Created May 25, 2020 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scriptschat/76fe6bafe043df1e808b5664f396b005 to your computer and use it in GitHub Desktop.
Save scriptschat/76fe6bafe043df1e808b5664f396b005 to your computer and use it in GitHub Desktop.
/**
* Returns node(s) for the given string attribute value of `data-test-id`
* @function findByTestAttribute
*
* @name
* @param {ShallowWrapper} wrapper - ShallowMounted Enzyme wrapper
* @param {string} attributeValue - value of data-test-id attribute as string
* for searching the nodes
* @returns {ShallowWrapper}
*/
export function findByTestAttribute(wrapper, attributeValue) {
if (!wrapper) {
return null;
}
return wrapper.find(`[data-test-id="${attributeValue}"]`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment