Skip to content

Instantly share code, notes, and snippets.

Created May 25, 2020 14:20
What would you like to do?
* 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