Created
October 1, 2016 20:04
-
-
Save valentin-radulescu-hs/12bc54348db5431fa171cd458ba4b748 to your computer and use it in GitHub Desktop.
Writing a visual test for Mugshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var expect = require('chai').expect; | |
| var Mugshot = require('mugshot'); | |
| var WebdriverIOAdapter = require('mugshot-webdriverio'); | |
| var webdriverio = require('webdriverio'); | |
| describe('Buttons', function() { | |
| var mugshot, webdriverioInstance; | |
| before(function(done) { | |
| var options = { | |
| desiredCapabilities: { | |
| browserName: 'chrome' | |
| } | |
| }; | |
| // 1. Prepare the browser instance | |
| webdriverioInstance = webdriverio.remote(options).init() | |
| .setViewportSize({width: 1024, height: 768}) | |
| .url('http://example.com') | |
| .then(function() { | |
| // 2. Create an adapter over it. | |
| var browser = new WebdriverIOAdapter(webdriverioInstance); | |
| // 3. Hand it over to Mugshot. | |
| mugshot = new Mugshot(browser); | |
| done(); | |
| }); | |
| }); | |
| it('should have the same color and size', function(done) { | |
| var captureItem = { | |
| name: 'green-button', | |
| selector: '.button-primary' | |
| }; | |
| // 4. Do the testing. | |
| mugshot.test(captureItem, function(error, result) { | |
| expect(error).to.be.null; | |
| expect(result.isEqual).to.be.true; | |
| done(); | |
| }) | |
| }); | |
| // 5. Close the browser instance. | |
| after(function() { | |
| return webdriverioInstance.end(); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment