Turn your manual testers into automation experts Request a DemoStart testRigor Free

Shopify Testing

Shopify Testing

Over 4.80 million websites are currently using Shopify across 175 countries. (source)

Shopify is a popular e-commerce platform that allows the creation of online stores. You are able to utilize their various tools and capabilities for establishing and maintaining your online commerce activities, which cover aspects such as crafting your website’s appearance, incorporating a shopping cart system, handling payments, keeping track of inventory levels, as well as promoting your business.

Shopify has a reputation for an easy-to-use interface, so even people without high-level technical abilities can use it comfortably. The platform also provides different integrations with other applications to improve what it can do, like software for managing finances, tools for marketing through email, and systems to handle customer relationships.

Although Shopify already has many important features, you can also make changes to your Shopify store by using code. This gives a greater level of customization and more features than what the usual theme settings and editors offer.

Shopify utilizes a range of programming languages for different purposes within its ecosystem.

  • Liquid: This is Shopify’s proprietary templating language. It’s used to build and customize Shopify themes. Liquid code is employed to dynamically load content like products, cart information, and customer data on Shopify storefronts.
  • JavaScript: JavaScript adds interactivity and dynamic features to Shopify storefronts. It’s used for client-side scripting to create interactive elements, handle user events like clicks, and enhance the user experience.
  • Rust: Rust is particularly beneficial for Shopify in areas such as writing high-performance web servers and extending Ruby with native code for better performance and interoperability.
  • Ruby: Specifically for Shopify Plus users, Shopify scripts are written in Ruby. These scripts enable custom business logic for the checkout process, such as applying discounts, customizing shipping methods, and modifying payment options.
  • Python (and other programming languages): Python is commonly used for back-end processes like API interactions, building custom applications, or data analysis and automation. While not specific to Shopify’s core, Python interacts with Shopify through its API, which is language-agnostic.

Testing Shopify customizations

While coding allows for extensive customization, it requires technical knowledge and may affect your store’s performance and future upgradability if not done correctly. If you’re building customizations for your Shopify store, then you can test the code using:

A thing to note here is that your test frameworks and tools will depend on the programming language you’re working with.

Unit testing

Through unit testing, you can ensure that all the units of code in your application are working as expected. This is a code-level check and works well, especially when your code base is growing, as is the case for Shopify applications. Here’s an interesting article that will further help you understand unit testing.

Coming back to writing unit tests for Shopify, you can use the popular test frameworks depending on the programming language you’re working with. Below is a brief explanation of the same.

Rust

Let’s talk about Rust code. If you’ve made modifications there, then you can add tests using the test syntax prescribed by Rust. For Shopify Functions specifically written in Rust, you can use the shopify_function crate, which simplifies the process of writing Shopify Functions. This crate includes a utility function run_function_with_input for unit testing, allowing you to quickly add new tests based on a given JSON input string.

JavaScript

For writing unit tests in JavaScript, you can use Jest or Vitest, a popular JavaScript testing framework. Jest enables automatic unit testing, provides code coverage, and allows for easy mocking of objects.

To begin, you’ll need to install Jest in your project using npm or another package manager. Then, write your unit tests in a separate file, typically named {filename}.test.js or {filename}.spec.js. In these tests, you can import the functions you want to test and define test cases using Jest’s syntax. For example, use test("test name", () => { ... }) to define a test and expect to assert expected outcomes.

Shopify Functions can be written in JavaScript (or TypeScript), and Shopify provides a JavaScript library to facilitate this. This library includes a TypeScript type generator and offers convenient functions to reduce boilerplate in your code. It’s important to note that to write functions in JavaScript for Shopify, you must have Node.js 16 or higher installed.

Integration testing

This type of testing is essential to ensure that different parts of your application interact correctly with each other and with Shopify’s platform. Here are several key areas where you can focus your integration testing efforts

  • Shopify API integrations: This includes creating, updating, and retrieving data from endpoints like products, orders, customers, and more.
  • Payment gateways and transactions: Ensure that the payment processing integrations in your app work seamlessly. This involves validating successful transactions, handling failed transactions, and testing different payment methods.
  • Third-party integrations: If your app integrates with third-party services like shipping carriers, marketing tools, or analytics services, you should test these integrations thoroughly.
  • Shopify Functions and scripts: For custom functionalities implemented via Shopify scripts or Shopify Functions, test their interaction with the Shopify checkout process, cart updates, and discount applications.
  • Webhooks and event handling: Verify that your app correctly receives and processes webhooks from Shopify. This includes testing for order creation, product updates, and other events.
  • User interface and user experience: In cases where your app adds elements to the Shopify admin or storefront, test the integration of these UI components to ensure they work well within Shopify’s interface.
  • App extensions and customizations: If your app offers extensions or customizations to the Shopify admin or storefront, test these thoroughly to ensure they don’t conflict with Shopify’s native features or other apps.
  • Multi-tenant architecture: If your app is used by multiple Shopify stores, test its ability to handle data and configurations across different stores without conflicts or data leaks.

Shopify’s provisions

There are some built-in capabilities within Shopify that let you test certain features. These test modes can be used both for manual and automated testing, depending on your setup and requirements.

  • Shopify’s Bogus Gateway: This is a mock payment provider that you can use to create test orders. When active, every order created is a test order. To simulate different types of transactions, you can enter specific credit card numbers (e.g., ‘1’ for a successful transaction, ‘2’ for a failed transaction, and ‘3’ for an exception). This method is useful for testing aspects like shipping, payment processing, and order confirmation without using real credit card details.
  • Shopify Payments Test Mode: This mode allows you to test your Shopify Payments setup by simulating payments with test credit card numbers. You can simulate successful transactions, as well as different types of failed transactions, using specific test card numbers. This is crucial for ensuring a seamless checkout experience for your customers.
  • Testing in Development Stores: In development stores, you can process unlimited test orders. However, real transactions are not allowed in development stores. You can’t use manual payment methods or draft orders created in the Shopify admin for testing in these stores.

End-to-end testing

Finally, we come to end-to-end testing, which views the application from an end user’s perspective. You want your online store to be as user-friendly and smooth as possible. For that, you need to test all the user workflows that are critical to your business.

You can learn more about the differences between integration and end-to-end testing.

Though Shopify does not have a prescribed tool to do this, you can make use of the various tools available in the market. Here are some of the options you can consider.

Selenium

Selenium has been synonymous with automation testing for a good reason. It has great flexibility, which makes it good for testing complicated e-commerce processes. It is also possible to perform tests on various web browsers and operating systems, which ensures that it works well with many different user settings.

Selenium works together with a lot of different programming languages and testing structures, which makes it more useful in complicated testing situations. It is open-source, so it gets a lot of support from the community, and there are many resources and documents one can find.

While Selenium provides a strong and adaptable system for full testing in Shopify, it needs a high level of technical/programming knowledge and can use many resources and time.

Cypress

Cypress is another favored choice, notable for its easy-to-use nature, especially when setting up and authoring tests. It’s designed to be more accessible for developers and testers.

It automatically waits for commands and assertions before moving on. This reduces the flakiness of tests due to timing issues. It provides good capabilities for debugging error messages that are easy to understand and gives you the option to use Chrome DevTools directly.

While many people appreciate Cypress for how simple it is to use and its very good debugging features, there are some issues with which browsers it can work on and how many computer resources it uses. Whether it fits well for testing on Shopify mostly relies on what the project needs exactly and the technologies used.

testRigor

Here’s a test automation tool that overcomes most of the challenges the above-mentioned options face. It is a powerful tool that uses generative AI to make automated testing easy and adaptable by all.

testRigor has a user-friendly interface and is a cloud-based solution, making it easy to set up and onboard. It supports testing across multiple browsers and platforms like the web and mobile, which comes in handy for e-commerce websites built using Shopify.

You can create test cases easily with testRigor, without worrying about learning a new programming language, as it supports writing tests in plain English statements. This doesn’t mean that it cannot do what other tools using programming languages do. In fact, it offers a rich library of powerful commands that will help you automate most of the tough end-to-end scenarios.

Here’s an example.
login
click on "Search Menu"
enter "Appraisal"
click on "Appraisal"
select "Manager"
select "Jessica Brown" from "Appraisal Reviewer"
select "Feedback Form" from "Appraisal Form"
click on "Start appraisal and send form"
check that page contains "Jessica Brown" roughly below "To Start"

Maintaining tests is also easy through self-healing on this platform, as it uses AI to make sure that you are able to focus on creating meaningful tests rather than being burdened with test maintenance. Since this tool does most of the heavy lifting for you, you can focus on testing your application rather than on the technical nitty-gritty of the testing tool.

Here’s an article that compares the three tools: Cypress vs. Selenium vs. testRigor.

Conclusion

You can build an excellent web store with the right features from Shopify. The developer guides from Shopify give detailed advice for checking and fixing problems, which is very helpful when doing projects in the Shopify environment. Match this with the testing tools that meet your requirements, and you should be all set to deliver great products with minimum effort and time.

Join the next wave of functional testing now.
A testRigor specialist will walk you through our platform with a custom demo.