menu

Testing Library

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

Channels
Team
Posts
Members
Info

render not calling ngOnInit

#testing-library/angular Note: If someone has a way to create a repro using testing-library/angular I'm happy to do that, but I've played around in CodeSandbox without success. My issue is that, contrary to prior experience, and my own thinking, it appears that ngOnInit isn't…

thumbsup
0
message-simple
5

Not detecting a changed DOM in Vue.

UPDATE: The false positive was a result of a return statement stopping tests from running after that line. Now I'm hitting an issue with the DOM not changing before the final expect executes. As far as I can tell I'm using async/await like the documentation says to. Is there…

thumbsup
0
message-simple
16

Practical use within Angular

The page for angular-testing-library is pretty minimal, and shows a wonderfully compact test with what looks like a magic "render" function. However, my current spec has about 80 lines of importing component modules, services, form modules, and setting up TestBed, etc before I…

thumbsup
0
message-simple
8

how can I properly test the click event in a selected item (fetched async) in…

This is what I've got so far. I'm stuck in the fetch process:

thumbsup
0
message-simple
19

Testing components that should throw

I'm using componentDidCatch on top parent component to handle generic errors. In my component therefore I'm throwing if some unknown API error happens and I can't handle it. Of course I would like to test this component if it throws, when API error happens. And it does, test…

thumbsup
2
message-simple
2

Check for state changes after firing a click event

Hey!! I am trying to test whether the state changes on my react component but I am struggling to understand why the data in my component is not updating. I need a second pair of eyes on it. The code: My test code is: …

thumbsup
0
message-simple
9

VS Code intellisense for jest-dom

Hey everyone, I've used jest.config.js file to extend Jest matchers like so: Somehow, intellisense does work with expect().toMatchDiffSnapshot() but not really with any of the jest-dom matchers. To make it work, I'd have to explicitly add import…

thumbsup
1
message-simple
7

Testing if something throws an Error

Hi! I am writing a custom hook and would like to throw an Error in some cases. I am trying to test if an error is thrown, but I only seem to get it to work (in my opinion) hacky way. Correct me, if I am wrong, I may not fully understand Errors, so there is a chance, my problem…

thumbsup
0
message-simple
7

Testing a component renders on parent hover

I'm trying to test that a component renders when hovering on another component. This requires mocking a mouse enter event but I couldn't find any examples. I saw other threads that talk about not needing to test CSS styles and hover effects. I don't believe that's the case here…

thumbsup
0
message-simple
1

SVG desc support?

Hey guys have you had to queryBy an SVG the desc? We specifically dont want to use the "title" attribute. We are trying to test to make sure certain svgs are rendered and think this would be the best way to test that functionality. Any help much appreciated! if this is not…

thumbsup
0
message-simple
2