Testing Concept Frontend
You first need to undestand the concept of frontend tests.
You should not test the implementation but the behavior
You test like the end user
For instance, imagine a login screen with email and password inputs and a submit button
The test should input the email and the password, then click in the submit button.
You should assert the API was called with the inputted data.
When using testing library you test against DOM
code:
const emailInput = getByTestId(emailTestId);
fireEvent.onChange(emailInput, { target: { value: 'email@email.com.br' } });
const passwordInput = getByTestId(passwordTestId);
fireEvent.onChange(passwordInput, { target: { value: 'pwd' } });
const submitButton = getByText('Login').closest('button');
fireEvent.click(submitButton);
// assert api was called properlyShares tags with
- "Simple" PagesA call "simple" pages: landing pages, blog posts, simple websites. These "simple" pages have a high level complexity of CSS and animations, 2 skills that I'm not so good yet,…
- Building from Scratch?why am I building my blog post from scratch? The idea is to learn all about the details to create great ux and dx I'd like to feel all the pain of writing everything in pure html…
- Bundle analyzeMost modern apps can’t be built without dependencies, so we need to analyze the final bundle of our application to make sure we are not shipping unnecessary code We can also use…
- CSSAvoid having too much CSS/styles in the product code Your Design System should use functional css to make it possible to extend it Your design system should have constraints to…
- CSS PracticeI've decided to practice converting some landing page and design to code This master will help me be a better css coder Smart Home System VPN landing page Final Version Links Luan…
Sign in with GitHub to reply.
Select any passage to quote it.
Comments