cljs-tlr.screen
Screen query utilities wrapping @testing-library/dom queries.
The screen object represents the global document body and provides query methods for finding elements. This namespace wraps those queries with Clojure-friendly function names.
Query variants follow a naming convention:
get-by-*- Throws if not found or multiple matchesquery-by-*- Returns nil if not found, throws on multiplefind-by-*- Returns Promise, waits for element to appearget-all-by-*- Returns array, throws if emptyquery-all-by-*- Returns array (may be empty)find-all-by-*- Returns Promise of array
Query priority (recommended order):
*-by-role- Best for accessibility*-by-label-text- Good for form fields*-by-placeholder-text- Fallback for inputs*-by-text- For non-interactive elements*-by-display-value- For filled form elements*-by-test-id- Last resort
debug
(debug)(debug element)(debug element max-length)Prints the current DOM tree for debugging.
With no arguments, prints the entire document body. With an element, prints just that element’s subtree. Useful for understanding why queries aren’t finding expected elements.
find-by-alt-text
(find-by-alt-text text)(find-by-alt-text text opts)Finds image by alt attribute. Returns Promise.
find-by-display-value
(find-by-display-value value)(find-by-display-value value opts)Finds input/select/textarea by current value. Returns Promise.
find-by-label-text
(find-by-label-text text)(find-by-label-text text opts)Finds form element by its label text. Returns Promise.
find-by-placeholder-text
(find-by-placeholder-text text)(find-by-placeholder-text text opts)Finds input by placeholder attribute. Returns Promise.
find-by-role
(find-by-role role)(find-by-role role opts)Finds element by ARIA role. Returns Promise that resolves when found.
find-by-test-id
(find-by-test-id id)(find-by-test-id id opts)Finds element by data-testid attribute. Returns Promise.
find-by-text
(find-by-text text)(find-by-text text opts)Finds element by text content. Returns Promise.
find-by-title
(find-by-title title)(find-by-title title opts)Finds element by title attribute. Returns Promise.
get-all-by-alt-text
(get-all-by-alt-text text)(get-all-by-alt-text text opts)Finds all images matching alt attribute. Throws if none.
get-all-by-display-value
(get-all-by-display-value value)(get-all-by-display-value value opts)Finds all inputs matching current value. Throws if none.
get-all-by-label-text
(get-all-by-label-text text)(get-all-by-label-text text opts)Finds all form elements matching label text. Throws if none.
get-all-by-placeholder-text
(get-all-by-placeholder-text text)(get-all-by-placeholder-text text opts)Finds all inputs matching placeholder. Throws if none.
get-all-by-role
(get-all-by-role role)(get-all-by-role role opts)Finds all elements matching ARIA role. Throws if none found.
get-all-by-test-id
(get-all-by-test-id id)(get-all-by-test-id id opts)Finds all elements matching data-testid. Throws if none.
get-all-by-text
(get-all-by-text text)(get-all-by-text text opts)Finds all elements matching text content. Throws if none.
get-all-by-title
(get-all-by-title title)(get-all-by-title title opts)Finds all elements matching title attribute. Throws if none.
get-by-alt-text
(get-by-alt-text text)(get-by-alt-text text opts)Finds image by alt attribute. Throws if not found.
get-by-display-value
(get-by-display-value value)(get-by-display-value value opts)Finds input/select/textarea by current value. Throws if not found.
get-by-label-text
(get-by-label-text text)(get-by-label-text text opts)Finds form element by its label text. Throws if not found.
get-by-placeholder-text
(get-by-placeholder-text text)(get-by-placeholder-text text opts)Finds input by placeholder attribute. Throws if not found.
get-by-role
(get-by-role role)(get-by-role role opts)Finds element by ARIA role. Throws if not found or multiple matches.
Role can be a string like “button”, “textbox”, “heading”, etc. Options map supports :name, :level, :pressed, :checked, etc.
get-by-test-id
(get-by-test-id id)(get-by-test-id id opts)Finds element by data-testid attribute. Throws if not found.
Use as a last resort when other queries don’t apply. Test IDs are invisible to users and don’t test accessibility.
get-by-text
(get-by-text text)(get-by-text text opts)Finds element by text content. Throws if not found.
get-by-title
(get-by-title title)(get-by-title title opts)Finds element by title attribute. Throws if not found.
log-testing-playground-url
(log-testing-playground-url)Logs a URL to testing-playground.com for the current DOM.
Opens the URL to get query suggestions for elements in your current DOM state.
query-all-by-alt-text
(query-all-by-alt-text text)(query-all-by-alt-text text opts)Finds all images matching alt attribute. Returns empty array if none.
query-all-by-display-value
(query-all-by-display-value value)(query-all-by-display-value value opts)Finds all inputs matching current value. Returns empty array if none.
query-all-by-label-text
(query-all-by-label-text text)(query-all-by-label-text text opts)Finds all form elements matching label text. Returns empty array if none.
query-all-by-placeholder-text
(query-all-by-placeholder-text text)(query-all-by-placeholder-text text opts)Finds all inputs matching placeholder. Returns empty array if none.
query-all-by-role
(query-all-by-role role)(query-all-by-role role opts)Finds all elements matching ARIA role. Returns empty array if none.
query-all-by-test-id
(query-all-by-test-id id)(query-all-by-test-id id opts)Finds all elements matching data-testid. Returns empty array if none.
query-all-by-text
(query-all-by-text text)(query-all-by-text text opts)Finds all elements matching text content. Returns empty array if none.
query-all-by-title
(query-all-by-title title)(query-all-by-title title opts)Finds all elements matching title attribute. Returns empty array if none.
query-by-alt-text
(query-by-alt-text text)(query-by-alt-text text opts)Finds image by alt attribute. Returns nil if not found.
query-by-display-value
(query-by-display-value value)(query-by-display-value value opts)Finds input/select/textarea by current value. Returns nil if not found.
query-by-label-text
(query-by-label-text text)(query-by-label-text text opts)Finds form element by its label text. Returns nil if not found.
query-by-placeholder-text
(query-by-placeholder-text text)(query-by-placeholder-text text opts)Finds input by placeholder attribute. Returns nil if not found.
query-by-role
(query-by-role role)(query-by-role role opts)Finds element by ARIA role. Returns nil if not found.
query-by-test-id
(query-by-test-id id)(query-by-test-id id opts)Finds element by data-testid attribute. Returns nil if not found.
query-by-text
(query-by-text text)(query-by-text text opts)Finds element by text content. Returns nil if not found.
query-by-title
(query-by-title title)(query-by-title title opts)Finds element by title attribute. Returns nil if not found.