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
Chat
Members
Info
Show previous messages

July 9, 2018 at 9:34am
it doesnt work if the dom is hidden by some other dom element
  • reply
  • like

July 9, 2018 at 8:42pm
anyone else having rendering issues with spectrum chat? I have to refresh the browser everytime i change routes
  • reply
  • like

July 16, 2018 at 3:51pm
Is there a way to test that getByText doesn't find a match?
  • reply
  • like

July 17, 2018 at 11:12am
Do you mean `expect(queryByText('foo')).not.toBeInTheDOM()`?
  • reply
  • like

July 23, 2018 at 1:06am
```expect(queryByText('foo')).toBeNull()```
  • reply
  • like

August 28, 2018 at 11:16am
Hey, new to react-testing-library, quick question, so instead of querying an element using its class, it uses getByText to find the element, it's kinda cool. I suppose the rational behind this is that if one changes the class name, it won't break the test. But my question here is what if the class name was changed accidentally, then the test won't break, but it might break the look for the site. Just wanna know your thoughts on this :)
  • reply
  • like
Hey , If you want to test whether an element has a class or not, you can do so.
I think that the idea behind getByText is that you should test a component, they way an user would: if a user wants to submit a form, she probably would look for a button with the text "submit" (or something like that) instead of looking for a button with a class="green"
like-fill
2
  • reply
  • like
Thanks yeah, I agree. After watching a few Kent's videos, he mentioned something like this.
like-fill
1
  • reply
  • like

October 7, 2018 at 11:29am
Hi everyone! I'm writing on behalf of group of open source enthusiasts coming from different Barcelona based meetups.
We are organizing an event on October 21st to celebrate Hacktoberfest https://hacktoberfest.digitalocean.com/. It will be a full day where we'll meet and contribute to open source projects.
If you know of any JS based open source project who could use some help—especially with beginner friendly pull requests—please send them my way! I'll share them with the rest of the community and maybe on the day of the event some member will pick them up.
like-fill
1
  • reply
  • like

November 13, 2018 at 9:28pm
Hello, first time poster here, when i try to render the same component twice for snap shot testing, i always end up getting the error TypeError: Cannot read property 'appendChild' of null and the error seems to stem from at render (node_modules/react-testing-library/dist/index.js:43:31) the only way i can circumvent this is by adding
const div = document.createElement("div")
const tree = render(
<componentToBeTested/>,
{
container: document.body.appendChild(div)
}
)
to every single component snap shot, and i dont think that is correct. I have been googling this question for days now. any help would be greatly appreciated!
  • reply
  • like

November 21, 2018 at 9:34am
Hi! Not sure if it's a bug or I don't understand API limitations properly... https://codesandbox.io/s/k2wr2ll10o showcases an example where a very simple test fails because of newline. DOM-testing-library has collapseWhitespace option which I believe should collapse whitespace in both its string argument and DOM innerHTML. But it collapses only the latter, so a newline in argument (referential) string breaks the comparison :(
Edited
  • reply
  • like

December 10, 2018 at 8:29pm
how do you insert code snippets in spectrum?
  • reply
  • like

December 11, 2018 at 8:03am
You type ``` on a new line and when you're done you type it again
like-fill
2
  • reply
  • like

January 14, 2019 at 11:37am
hi, how to fire `online` event use react-testing-libray
  • reply
  • like

February 11, 2019 at 11:35pm
I see lots of examples in CodeSandbox, but today when I tried a number of them the tests are always failing, with errors like Can't find variable: describe or undefined expect or tests just hanging. As a concrete example: https://codesandbox.io/s/lp057z0vxz - it is from How NOT to test custom React hooks (and how to test them) video https://youtu.be/0e6WCQYg5tU). Also the tests from the testingjavascript course seem to be failing with errors like Unexpected frame by generating stack, Can't find variable: expect, Can't find variable: afterEach.
Is it just me or more people observe these problems with Codesandbox recently?
  • reply
  • like

February 13, 2019 at 3:33pm
Hmm - looks like ReferenceError: describe is not defined is caused by jest-in-case:
ReferenceError: describe is not defined
at cases (https://62vm6x3w3z.codesandbox.io/node_modules/jest-in-case/index.js:23:3)
Edited
  • reply
  • like

March 2, 2019 at 8:07pm
I see lots of examples in CodeSandbox, but today when I tried a number of them the tests are always failing, with errors like Can't find variable: describe or undefined expect or tests just hanging. As a concrete example: https://codesandbox.io/s/lp057z0vxz - it is from How NOT to test custom React hooks (and how to test them) video https://youtu.be/0e6WCQYg5tU). Also the tests from the testingjavascript course seem to be failing with errors like Unexpected frame by generating stack, Can't find variable: expect, Can't find variable: afterEach.
Is it just me or more people observe these problems with Codesandbox recently?
had the same experience a couple of days ago
  • reply
  • like

March 4, 2019 at 2:09am

March 4, 2019 at 8:51am
Not sure I find this bot useful. Now I get double notifications for every new post. But maybe it's just me
like-fill
2
  • reply
  • like

March 26, 2019 at 9:55am
Hi guys! How do you test executing modal by clicking button? Is there any way to test is modal exist inside DOM without rendering it on test?
  • reply
  • like

April 2, 2019 at 6:09pm
I test modals by checking if the rendered content changes
  • reply
  • like
Not sure if thats the right approach though
  • reply
  • like

April 18, 2019 at 8:38pm
Is it expected that one add the attribute data-testid to their actual components, just to run a test?
  • reply
  • like
Show more messages