menu

Testing Library

Simple and complete DOM testing utilities that encourage good testing practices.

Channels
Chat
view-forward
# All channels
view-forward
# General
view-forward
# General Help
view-forward
# Angular Help
view-forward
# Cypress Help
view-forward
# DOM Help
view-forward
# React Help
view-forward
# TestCafe Help
view-forward
# Vue Help
view-forward
Team
Posts
Members
Info

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?

thumbsup
0
message-simple
5

TypeError: document.createRange is not a function

Hi everyone, After upgrading to latest react-dom and react testing library run into these issues with my tests TypeError: document.createRange is not a function …

thumbsup
0
message-simple
0

Mocking DOM node

Hi guys, 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"

thumbsup
0
message-simple
1

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!

thumbsup
0
message-simple
3

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 https://developer.microsoft.com/en-us/fabric#/controls/web/button …

thumbsup
0
message-simple
12

How to ignore some lines in the snapshot comparison?

Hey guys! 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: …

thumbsup
0
message-simple
2

Test plain HTML + vanilla JS?

At the moment I want to test a plain HTML page. However, the Javascript is not executing. 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?

thumbsup
0
message-simple
0

getBy queries representing stale values?

This is something I'm not too sure about. I may be performing an "anti-pattern" and would like to confirm with the community. I'm writing a test to change the value of an input and assert that a button is enabled when the input has a value: The above test fails when asserting if…

thumbsup
0
message-simple
1

How to test the code which uses IntersectionObserver API.

So, I was writing one custom hook useInstersectionObserver. What should be the right approach to test this kind of react custom hook. Here is the link to the code: https://codesandbox.io/embed/useintersectionobserver-sbz54 Note: I am new to react testing library, might be…

thumbsup
0
message-simple
1

Fire scroll event with specified X, Y positions

I have a UI that changes if the user has scrolled at least 100 pixels in the Y direction, so I would like to fire an event similar to this: fireEvent.scroll(window, {scrollY: 101}) The event is fired, but the scrollY value does not change. Can anyone help?

thumbsup
0
message-simple
1