Access elements in shadow root
I have one question which came up during developing a component lately. Is it somehow possible to access shadow DOM elements with the test lib?
toHaveTextContent not exact matching.
toHaveTextContent matches on the content containing a value. I was getting false positives when testing that a value of 100 was passing when tested for a value of 10. I resorted to the following expect(countIndicator.textContent).toBe('10') and was interested to know if this was…
Testing combobox filtering returning no results
Hey all, I am trying to test a combobox library I built, and having some troubles. The library works as i'd expect in the browser, elements are getting filtered and are visible within the dom but when writing tests, i keep getting no results returned. Demo:…
Testing visibility of an element with CSS
I'd like to test if a component is visible using toBeVisible(), but that method doesn't work if CSS is used to show or hide elements: https://github.com/testing-library/jest-dom/issues/116 is there any way to get around this?
TypeError: document.createRange is not a function
After upgrading to latest react-dom and react testing library run into these issues with my tests
TypeError: document.createRange is not a function …
Mocking DOM node
I have a component which is using data that is being grabbed by an attribute of a specific DOM node. Do you know how I can mock that DOM node/the attribute of the DOM node?
i.e in this example how can I mock the node which has id "region"
Can Testing Library run on a live site?
For reasons that are too long to go into here, I'm not able to build or deploy the code locally but instead I push it to the server. Is it possible to use Testing Library to run tests on a live site? Thanks!
getAllBy...(_) for a nested button on 3rd party library with dropdown
I am trying to test the following scenario:
I have a list of "command bar buttons" with the "split" option set to true from this library
How to ignore some lines in the snapshot comparison?
I'm trying to use snapshots to check there is no change in the visual of my react component.
but my component show a text with a date for example: …
Test plain HTML + vanilla JS?
Perhaps because it is not actually loaded, and I'm just running a query against plain text?
How can I create an actual DOM to test against?