























I had occasion to finally get to one of my goals from last year - and that was to introduce some testing to my front end development.
My goal was to have a way to have a before/after visual regression test. The open source Wraith project, from the BBC, fits the bill wonderfully.
This post is merely meant to be a step-by-step procedure to get Wraith up and running. I'm not going to provide any context to what each step means.
First off, this post assumes that you're running Mac OS X, and already have Ruby installed. This post also assumes that you want to use the "history" mode in Wraith - where you are taking two snapshots of the same URL. (The "standard" mode requires two different URLs).
Open a terminal and enter this:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Hit enter and enter password at prompts
brew install imagemagick
brew install phantomjs
brew install casperjs --devel
sudo gem install wraith
I needed sudo, anyway.
cd path/to/project
wraith setup
This creates two files:
/javascript/snap.js/configs/config.yamlSee this example config file for an example.
wraith history configs/config.yaml
If you get "unable to find config" errors, check the YAML syntax.
wraith latest configs/config.yaml
This will take a bit, so be patient.
It will be found in the "directory" you configured - e.g. 'shots/gallery.html'. Just open that file in your favorite browser.
This is all with the defaults as presented by wraith. There is nothing to stop you from rearranging directories, if it makes sense. For instance, in my project I consolidated everything into /tests/.
If you change the config file - e.g. add more paths, etc, delete your inital shots and shots_history directories.
My initial instinct is to not commit shots generated by your tests into a version control repo. (In git, this would be done by modifying your .gitignore file) There are a lot of image files generated, and binary files tend to make git repos balloon in size if they are running amok.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。