The project is in a healthy, maintained state
A minitest plugin for testing Shopify Liquid themes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Minitest Shopify

Prototype of a minitest test class with capybara assertions capable of rendering sections and snippets of a liquid based Shopify theme.

Example

MinitestShopifyThemes.configure do |config|
  config.theme_root = File.join(__dir__, "theme")
  config.selenium_driver = :selenium_chrome_headless
  config.layout_file = "layout/theme"
end
require "minitest/autorun"
require "minitest_shopify_themes"

class TestCard < MinitestShopifyThemes::LiquidTest
  def test_renders_a_card
    render template: "snippets/card", variables: { comment: default_comment }
    assert_text "Hello world!"
    assert_text "John Doe"
  end

  private

  def default_comment
    {
      id: 1,
      created_at: "2023-07-20T19:31:35Z",
      content: "Hello world!",
      author: {
        id: 1,
        name: "John Doe"
      }
    }
  end
end

You can also use selenium to run tests that involve JavaScript or assets:

require "minitest/autorun"
require "minitest_shopify_themes"

class TestCardView < MinitestShopifyThemes::ViewTest
  def test_javascript_enabled_card
    render template: "snippets/js-card", variables: { comment: default_comment }
    within "#comment-1" do
      assert_text "Javascript is enabled"
      assert_no_text "Hello World"
    end
  end

  private

  def default_comment
    {
      id: 1,
      content: "Hello world!",
    }
  end
end

Installation

This is an experiment for the time being, if you want to try it out for yourself you can add the following definition to your gemfile:

gem "minitest_shopify_themes", git: "https://github.com/nebulab/minitest_shopify_themes.git", branch: "main"