testing-library / testing-library-docs

docs site for @testing-library/*
https://testing-library.com
MIT License
455 stars 711 forks source link

Improve Angular Testing Library API documentation #653

Open ChristophWalter opened 4 years ago

ChristophWalter commented 4 years ago

I am new to Angular Testing and stumbled across some misunderstandings while writing my first tests. I would like to help you improve it, so let's start collecting the issues. 🙂

  1. The example for the declarations (within RenderOptions) is wrong. It configures the providers. Furthermore there is no descriptions for the providers option. https://testing-library.com/docs/angular-testing-library/api#declarations
  2. We might also add a note which of the RenderOptions are passed to the Angular TestBed. Or even separate those from the added render properties.
  3. Explaining that this library still works with the core testing functionality of Angular under the hood will also help to implement non-standard situations. For example in one test I needed to interact with a service. This can be done with the Angular TestBed: TestBed.get(TargetService).init();
timdeschryver commented 4 years ago

Hi, I'm the maintainer of Angular Testing Library. Those are all valid points, feel free to create a PR and ping me for a review.

shaman-apprentice commented 1 year ago

What do you think about aligning the API behavior to React's API? I stumbled over rerender and first created a bug here as I was sure about my unchecked React-based assumptions:

In the React-world, rerender on a (legacy) class component, results in a call to render and a call to componentDidUpdate with previous props as parameters, but not to a call to constructor or componentDidMount.

On the other hand, in the Angular-world rerender does re-create the component from scratch. Meaning constructor is called again and ngOnChanges with initial simpleChange object without previous values / firstChange is set to true for each input property.

So my thoughts:

What do you think? Should I create an own issue for this discussion?

timdeschryver commented 1 year ago

@shaman-apprentice you can open a PR to update the docs. We can discuss this if we have more breaking changes, maybe soon because testing library dom is going to have some breaking changes

shaman-apprentice commented 1 year ago

@shaman-apprentice you can open a PR to update the docs. We can discuss this if we have more breaking changes, maybe soon because testing library dom is going to have some breaking changes

Thx! I created a PR with a suggestion for current behavior. Is there some process / guidelines how the api section of the docs should be aligned with the js docs from models.ts?

After some thoughts I still like the idea of the breaking change to remove change and let rerender do what change currently does. If you are open to this change, how should we proceed with this idea? Should I create a docs PR for it or maybe an own issue?

timdeschryver commented 1 year ago

@shaman-apprentice I try to keep it up-to-date, and I usually copy paste the content from the docs to the models (or the other way around). When the PR is merged, we can also update the models file.

For the breaking change, let's open an issue in ATL and discuss it there.