Last active
September 5, 2023 13:30
-
-
Save sibelius/bf49eeb2eada00d63b533866cc510556 to your computer and use it in GitHub Desktop.
get all data-testid from your DOM, useful when working in testing-library tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// thanks to http://twitter.com/@KrComet | |
export const getAvailableTestIds = () => { | |
// eslint-disable-next-line | |
console.log(new Set([...document.querySelectorAll('[data-testid]')].map((el) => el.dataset.testid))); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment