as of version 5.0.3 Edit this page on GitHub

How to use Karma for storefront tests

Introduction

Karma is a JavaScript test runner for Shopware's storefront. The tests themselves are written in Jasmine.

The main goal of Karma is to create a productive testing environment for developers, where they don't have to set up multiple configurations, and can just write code and get instant feedback from their tests.

Requirements

Karma requires Node.js and npm to be installed on your system. Node.js is available on a majority of systems and distributions. If your system isn't listed below, please use the official Node.js installation guide.

Installation

Now that all requirements are installed, we can install Karma and its dependencies. First of all, please switch to the directory themes/Frontend/Responsive and execute the following command:

npm install karma karma-phantomjs-launcher karma-jasmine jasmine-core karma-junit-reporter

Running tests using the command line

Running the storefront tests is easy. Start up for favourite terminal application and switch to the themes/Frontend/Responsive directory of your Shopware installation. Now you can run the tests using the following command:

karma start karma.conf.js

Using the build script

If you feel more comfortable using our build script, you can use it as well. Head over to your Shopware installation and go to the build directory You can execute the tests using the following command:

ant karma-shopware-continuous

Integrate Karma in PhpStorm

PhpStorm is our recommended IDE. In the plugin repository, you can find a Karma plugin which can run the storefront tests. Here's how you can install and use it: Installing, Updating and Uninstalling Repository Plugins