DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Driving DevOps With Smart, Scalable Testing
  • Unit Testing Large Codebases: Principles, Practices, and C++ Examples
  • Practical Use of Weak Symbols
  • Generate Unit Tests With AI Using Ollama and Spring Boot

Trending

  • Strategies for Securing E-Commerce Applications
  • Simplifying Multi-LLM Integration With KubeMQ
  • Optimizing Serverless Computing with AWS Lambda Layers and CloudFormation
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. Why Is Testing So Important in Frontend?

Why Is Testing So Important in Frontend?

Testing in Frontend, when done correctly, will achieve our users to be contentful and have a good performance experience using our applications.

By 
Beste Bayhan user avatar
Beste Bayhan
·
Nov. 18, 22 · Opinion
Likes (1)
Comment
Save
Tweet
Share
8.3K Views

Join the DZone community and get the full member experience.

Join For Free

According to Uncle Bob, tests are part of the system; many developers think the opposite since they are not deployed. He declares that it is a catastrophic point of view since the test’s role is to support the development and keep the system robust and easy to change. (Clean Architecture, Robert C. Martin, 2018)

In Frontend, it is commonly tested, the interactions of the end users with our application. We should guarantee to our users when they log in, open a pop-up, add a comment or do any other interaction with our apps to not encounter any errors and live undesirable experiences.

Testing in Frontend, if it is done correctly, will achieve our users to be contentful and have a good performance experience using our applications. On the other hand, for developers, it will save a lot of time to resolve bugs, or when adding new features, it will not break previous behaviors of the code.

Why Can Testing Be Disadvantageous? How to Design a Testing System?

Testing requires time and also consistency with the changes during development. Also, with the evolution of devices and browsers, we need to be up-to-date. In Software Testing, there is a concept known as the Fragile Tests Problem. This can be defined as one change in a system that causes hundreds of tests to fail. Uncle Bob emphasizes the importance of a well-designed testing system for the desired benefits of stability and regression for our systems (Clean Architecture, Robert C. Martin, 2018).

We will describe some methodologies and strategies that may help with the design of our testing systems:

Martin Fowler, in his article ‘On the Diverse And Fantastical Shapes of Testing‘, tells about his moment when they asked a test expert the definition of the unit test. He says that the answer of this expert was that he covered 24 different definitions of unit tests on the first morning of his training course. Since there are many different definitions of the unit test, in this article, we will include the one which is called the solitary test by Fowler.

In the famous pyramid of testing, in the base, we encounter unit tests that have less coverage of tests, but they are the fastest ones to execute. In the second level, we see the integration test, which has more coverage, but they are slower since it may connect with external parts. Finally, we have E2E tests or some call acceptance tests, which cover a huge part of the application, but they are the slowest ones to execute.

Unit tests check our components in isolation to work properly. They also cover edge cases to test, and this leads our code base to be more reliable. Unit tests are followed by the implementation of integration tests. Integration tests check the communication between two software units or modules developed independently when they are connected to each other. They analyze the behavior of systems when they are connected and also check the interaction between the microservices. They also include the API connection, which is why they are slower regarding unit tests because the connection can be delayed, or the service could be down. In the front end, integration tests are used to check the data that returns API has the correct object, array, or format.

E2E tests simulate user behavior and check all the interactions of the user with our application. They are specialized versions of integration tests that are executed in real browsers. They generally run before merges or releases because it may take hours to finish the execution of the test. 

In the following, we also mention the testing techniques, such as Accessibility and UI:

Accessibility Testing checks that the user interface is easily usable by every user and makes our application usable for people who have disabilities.  Jest-axe is a great library for testing in Jest, which allows us to check the accessibility of our apps. 

UI tests check if the user interface of our application works correctly. If a user enters input, clicks on a checkbox, or deletes an element, should work properly and update the state of the UI as expected.

Some Frontend Testing Libraries Review

Jest is a library used mostly for unit and integration testing in Frontend. It is very fast for big projects with many test files for its mechanism implementation of clever parallel testing.

Testing Library is a library where we can write unit and integration tests. It helps with convenient selectors, firing events, configuration, dealing with asynchronous code, and many more.

Cypress is a library that injects its tests into a website that Cypress.io runs itself in the browser. We can write unit, integration, and end-to-end tests efficiently. 

It provides a faster experience to developers, and we can see the errors easily on its browser.

Applitools is used for Visual Regression Testing. With its advanced AI techniques, it detects differences between Images and DOM. It is very useful to check if our site’s appearance is the same as the previous one or if an error occurred. Also, it checks for different browsers and platforms if the user can see correctly any item or button on the website correctly when on mobile or the web.

Conclusion

Testing in the front end should be part of our development to fix issues in our code before they go to production. We should write unit tests that examine every functionality in our applications and also develop integration tests to check if all components and modules work correctly together. On the other hand, we should write E2E tests that automate the manual-click-testing and center how users would interact with our application.

We should write tests to provide confidence and not only improve metrics.  As Robert C. Martin says, we should avoid writing tests that are strongly coupled to the system. Because even the most trivial change can generate many tests to break. 

unit test

Published at DZone with permission of Beste Bayhan. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Driving DevOps With Smart, Scalable Testing
  • Unit Testing Large Codebases: Principles, Practices, and C++ Examples
  • Practical Use of Weak Symbols
  • Generate Unit Tests With AI Using Ollama and Spring Boot

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!