Experience the power of Magento end to end Automation testing - Cypress - part 2.

Michał Paprocki

Thu Sep 12 2024

Are you keen on testing your website using Cypress?

BOOK A CALL

Magento Automation Testing in Practice

We leverage Cypress testing to ensure the robustness of our applications. We make strategic decisions to employ automation testing in conjunction with manual testing as the complexity of the store grows. This prudent approach optimizes and safeguards the development process, ensuring efficiency and security at every step.

Test Driven Development

As previously mentioned in the Magento Automation Testing - part 1, the timing of implementing testing in Magento stores is crucial. With continuous developments taking place, waiting for the completion or milestones of the process is not an option. 

It is vital to break down the code into smaller components representing unique features and continually test them to ensure the code and feature quality. By doing so, we can ensure the delivery of a development service that meets the highest standards.

Cypress testing advantages

When it comes to Magento automation testing nowadays, Cypress is a popular choice. There are three key benefits that make it stand out:

  1. Firstly, Cypress is incredibly user-friendly, allowing you to implement and run multiple tests simultaneously in a matter of minutes.
  2. Secondly, Cypress provides the convenience of screenshots, and videos allowing you to compare the before and after effects easily and follow the checking process step by step.
  3. Lastly, Cypress is an open-source asset with a thriving community, which we greatly appreciate.

Overall, Cypress is an excellent tool for Magento automation testing, offering ease of use, valuable visual comparisons, and the support of a lively community.

Cypress testing Case Studies

As you may have already noticed, you have the flexibility to conduct tests on various aspects of your store, including customer journey, checkout process and shipment.

In the following examples, we will showcase how automation testing has proven valuable in our practical experience.

Development process optimization

Automation tests are utilized to verify the system post-deployment. These tests promptly detect bugs within minutes of the deployment's completion. They provide assurance to the team that everything is functioning correctly or alert the testers to investigate specific issues without the need for extensive analysis across the entire system. Automation tests excel at identifying and pinpointing exact problems.

Customer journey investigation

In the majority of cases, our testing focuses on the following areas:

  • Order processing.
  • Checkout procedures.
  • Payment methods.
  • Price compliance.
  • Shipment options.
  • Payment methods.

The benefit lies in the fact that automation tests can be effortlessly replicated, conducted at a rapid pace, and result in time savings by minimizing human involvement, while simultaneously eliminating errors.

Time-saving thanks to automation tests

Instead of spending half an hour manually testing one store, we can now test multiple stores in just 5 minutes. This allows manual testers to focus on double-checking specific issues, optimizing the process and enhancing business security.

Automation tests graduality benefits

Automation tests can be tailored to address specific issues within a single store, such as examining a particular shipment or payment method in a specific market referring to individual products. This level of granularity is highly advantageous, as it enables comprehensive analysis of precise concerns.

Automation testing step-by-step

When opting for automation testing, we are presented with two choices: utilizing pre-made tests for simpler scenarios or crafting new ones tailored to specific situations. The decision ultimately rests on the unique needs and requirements of the business at hand. 

Cypress Automation tests ready to go for Magento

We often use ready-to-go automation tests like the following one Magento 2 Cypress Testing Suite. There are around 70 tests working smoothly with Magento 2.3.x / 2.4.x, Hyvä (1.1.17) or Luma-based themes.

You can test the following areas:

  • Account creation and activities,
  • Product search,
  • Category Page,
  • Home Page,
  • Product Page,
  • Checkout Guest and Logged in,
  • Cart actions,
  • Bundle Products,
  • CMS Page,
  • Contact form,
  • Back-end data.

Custom Cypress Automation tests for Magento

When the situation calls for it, it becomes necessary to develop specific tests. In such cases, Cypress, being an open-source tool, becomes the obvious choice for Magento developers. Admittedly, this approach requires more time and money resources, but it yields substantial dividends in the form of enhanced e-commerce security - a critical component for complex stores.

The test operates on static data, meaning that whenever there is a change in the live store, the tests also need to be adjusted accordingly. However, it is possible to regularly run automated tests using a predefined set of tests or by making slight modifications to them.

Every year, we test an IoT marketplace for Black Friday, and we conduct automation tests using the same set of tests. This approach brings considerable time and cost savings, while continuously enhancing security during the peak season. Embracing long-term strategies and taking decisive action always yields fruitful results.

Magento Automation test trigger

Automated tests not only execute automatically but can also be triggered by specific actions, such as deployment. In fact we have 3 options for firing tests:

  • Manually, 
  • Automatically during deployment, 
  • Cyclically.

Frequent code updates and the implementation of new features can bring about substantial changes to the codebase. Performing automation tests immediately post-deployment proves to be an excellent choice, ensuring smooth functionality and peace of mind.

The tests are automatically executed live once the deployment is completed. Obtaining results merely takes minutes, offering a significant foundation for quality assurance. These outcomes serve as a valuable starting point, ensuring excellence with utmost efficiency.

Magento Automation test in progress

Cypress allows for browser virtualization, operating within this virtual environment to search for specific HTML code parts and perform actions on them. It offers compatibility across various browsers including Chrome, Safari, iOS, and Android, on both mobile and desktop platforms. 

During the initial stage, the test replicates customer actions such as ordering, adding products to the cart, selecting payment methods, and choosing shipment options. This ensures an accurate simulation of the customer experience.

After the simulations of customer actions, a thorough verification process is conducted to ensure the correct placement of data in the appropriate database and conformity of the information displayed on the front page with that stored in the database.

Video recording and screenshots

Cypress allows for video recording and with the use of the Cypress extension https://percy.io/, capturing screenshots at each testing stage becomes a reality. This allows for effortless comparison of the before and after states when incorporating changes.

Capturing video recordings and screenshots at every step of the testing process enables the accumulation of a substantial amount of data.

Video Cypress examples

This facilitates efficient examination while ensuring accuracy. It allows for the identification of potential challenges before they have a significant impact on the business, ensuring proactive management.

The provided data facilitates project management by offering valuable insights that empower smart decision-making based on meaningful information.

Visual regression tests

Thanks to Percy.io usage after each step, we can compare screenshots and videos to identify any missing elements, such as banners or icons that may not be easily detected during manual testing. 

Verifying the before and after versions using screenshots or videos allows us to notice differences and take necessary actions to make improvements. 

Payment methods automation testing

Testing payment methods can be a challenging task due to the secure nature of payment gateways aimed at preventing fraudulent orders. However, we continuously strive to find effective solutions that allow us to test the process without compromising transaction security.

We prioritize transaction security to safeguard both users and store owners, ensuring their protection and peace of mind. We recommend the following solution to protect your Magento store Subuno - Fraud Prevention Module for Magento


Shipping methods automation testing

Automating the testing of complex shipping methods poses a significant challenge. These methods are frequently tailored to the specific requirements of different markets and product categories. 

Variables such as size, weight, bundled products, and customer preferences for delivery dates and time frames all influence the selection of appropriate shipping methods. Other factors, such as shipment optimization date and vehicle, can also come into play. 

It is crucial to maintain accuracy and efficiency in this multifaceted process. Automation tests become more complex as well because of the environment. 

Magento 1 and Magento 2 automation tests 

When migrating from Magento 1 to Magento 2 or operating on two separate instances concurrently, it becomes crucial to compare the data between them. Performing this task manually would consume at least an entire month, evaluating hundreds of products, prices, and shipping methods.

However, through automated testing, this process can be accomplished within a few hours. This not only saves an ample amount of time in testing and development but also allows for budget optimization.

Magento Automation Testing start in 3 steps 

In conclusion, we highly recommend taking a proactive approach to the decision-making process when implementing automation testing. This entails taking proactive measures to mitigate bugs and issues, thereby enhancing predictability within the situation.

The initial step entails determining whether conducting testing permanently or only under specific circumstances, such as during peak periods like Black Friday or when introducing new features and performing large deployments, brings significant advantages. 

The next step is to determine which aspects to test. This could involve analyzing the entire customer journey, focusing on a particular feature, or solely examining Newsletter subscriptions. The choice should align with your specific requirements and business objectives.

When considering automation tests, the third decision lies in choosing between ready-made or custom ones. If the store isn't overly complex and can be adequately covered by existing tests, there's no need to invest in developing customized sets.

To ensure informed decision-making, it is vital to have a reliable Technology Partner by your side — someone experienced enough to provide valuable insights and know-how. Technology plays a crucial role in the realm of e-commerce, making this partnership even more crucial.

Magento Automated Testing - Part 1.


Michał Paprocki

Michał Paprocki

Thu Sep 12 2024

Share:


Fabrity Commerce Sp z.o.o

HQ in Warsaw

PLATINIUM 5 Building

44a Domaniewska Street
02-672 Warsaw

Branch in Lodz

Ogrodowa Office

8 Ogrodowa Street
91-065 Lodz

+48 22 343 06 00

Branch in Rzeszow

SKYRES Office

18 Warszawska Street
35-205 Rzeszow

+48 22 448 70 00

Branch in Bialystok

CITY OFFICE

Cieszynska 3A
15-371 Bialystok

Branch in Poznań

Poznań Science & Technology Park

Rubiez C1/4 Street
61-612 Poznan

VAT ID: PL9721244346
National Register of Economic Units (REGON): 302441526
National Court Register (KRS): 0000914436