Good testing practices with 🦔 Angular Testing Library #280
Replies: 3 comments 11 replies
-
From angular 17, We have web test runner. |
Beta Was this translation helpful? Give feedback.
-
I had a bit of trouble with the inputValues.forEach(({ value, label }) => {
const control = screen.getByLabelText(label);
if (control.tagName === 'MAT-SELECT') {
userEvent.selectOptions(control, value.toString());
} else {
userEvent.type(control, value.toString());
}
}); The following worked: for await (const { value, placeholder } of inputValues) {
const control = screen.getByLabelText(label);
if (control.tagName === 'MAT-SELECT') {
userEvent.selectOptions(control, value.toString());
} else {
await userEvent.type(control, value.toString());
}
}); Would there be any reason for my difficulties withing an async test? Thanks for these articles, they are great! |
Beta Was this translation helpful? Give feedback.
-
Is there a way to somehow document each test case? I mean still use one big test, but still get list in the end like if this test was split by |
Beta Was this translation helpful? Give feedback.
-
Good testing practices with 🦔 Angular Testing Library
The Angular Testing Library provides utility functions to interact with Angular components, in the same way as a user would. This brings more maintainability to our tests, gives us more confidence that our component does what it's supposed to do, and it improves the accessibility which is better for our users. All these benefits, plus you'll see that it's fun to write tests in this way.
https://timdeschryver.dev/blog/good-testing-practices-with-angular-testing-library
Beta Was this translation helpful? Give feedback.
All reactions