You have written a new test and should save a reference image for it:
gemini update
Running tests
Start selenium-standalone in a separate tab before running the tests:
selenium-standalone start
Run gemini tests:
gemini test
Dependencies
Required software:
WebDriver server implementation. There are several options:
Selenium Server — for testing in
different browsers. Launch with the selenium-standalone start command (if you will get error like "No Java runtime present, requesting install." you should install Java Development Kit (JDK) for your OS.).
ChromeDriver — for
testing in Google Chrome. Launch with the chromedriver --port=4444 --url-base=wd/hub command.
PhantomJS — launch with the phantomjs --webdriver=4444 command.
Compiler with support for C++11 (GCC@4.6 or higher). This is a
png-img requirement.
Compiling on Windows machines requires the node-gyp prerequisites.
Installing
To install the utility, use the npminstall command:
npm install -g gemini
Global installation is used for launching commands.
Configuring
Gemini is configured using a config file at the root of the project.
Gemini can use one of the following files:
.gemini.conf.js
.gemini.conf.json
.gemini.conf.yml
.gemini.js
.gemini.json
.gemini.yml
Let's say we want to run our tests only in the locally installed PhantomJS.
In this case, the minimal configuration file will only need to have the root URL
of your web app and the WebDriver capabilities of PhantomJS:
For example,
See the details of the config file structure and available
options.
Writing tests
Each of the blocks that are being tested may be in one of the determined states.
States are tested with the help of chains of step-by-step actions declared in a block's
test suites.
For example, let's write a test for a search block at
yandex.com:
We are creating a new test suite yandex-search, assuming that we will capture the
.search2__input element from the root URL http://yandex.com. We know that the
block has two states:
plain — right after the page is loaded
with text — with the hello gemini text inserted into .search2__input .input__control
States are executed one after another in the order in which they are defined, without the browser
reloading in between.
To complete the test creation procedure, you need to take reference shots using
the following command:
gemini update [paths to test suites]
To launch a test (to compare the current state of a block with a reference shot), use
the command:
gemini test [paths to test suites]
See the details of interaction with CLI and available
options.
GUI
You can use the Gemini graphical user interface instead of the command line. It
is located in the gemini-gui package
and must be installed additionally:
npm install -g gemini-gui
GUI advantages:
Handy preview of reference shots
Clear real-time demonstration of the differences between a reference shot and
the current state of a block
Easy to update reference shots
Plugins
Gemini can be extended with plugins. You can choose from the existing
plugins or write your
own. To use a plugin, install and enable it in your
.gemini.yml:
system: plugins: some-awesome-plugin: plugin-option: value
HTML report
To see the difference between the current state of a block and a reference picture
more clearly, use the HTML reporter - plugin for gemini. This
plugin produces HTML report, which displays reference image, current image and
differences between them, for each state in each browser. When all tests are
completed, you will see a link to HTML report.
Programmatic API
To use Gemini in your scripts or build tools, you can use the experimental
programmatic API.