chai-mugshot
Advanced tools
Comparing version 0.1.0 to 0.2.0
17
index.js
var Q = require('q'); | ||
module.exports = function(mugshot) { | ||
/** | ||
* Chai-Mugshot Plugin | ||
* | ||
* @param mugshot - Mugshot instance | ||
* @param testRunnerCtx - Context of the test runner where the assertions are | ||
* done | ||
*/ | ||
module.exports = function(mugshot, testRunnerCtx) { | ||
return function(chai) { | ||
@@ -28,6 +35,10 @@ var Assertion = chai.Assertion; | ||
} else { | ||
if (testRunnerCtx !== undefined) { | ||
testRunnerCtx.result = result; | ||
} | ||
try { | ||
_this.assert(result, msg.affirmative, msg.negative); | ||
_this.assert(result.isEqual, msg.affirmative, msg.negative); | ||
deferred.resolve(); | ||
} catch(error) { | ||
} catch (error) { | ||
deferred.reject(error); | ||
@@ -34,0 +45,0 @@ } |
{ | ||
"name": "chai-mugshot", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Chai plugin for Mugshot visual testing lib", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"browser": "phantomjs --webdriver=4444", | ||
"linter": "eslint ." | ||
"lint": "eslint ." | ||
}, | ||
@@ -32,3 +32,4 @@ "repository": { | ||
"peerDependencies": { | ||
"chai": "^3.2.0" | ||
"chai": "^3.2.0", | ||
"mugshot": "0.2.0" | ||
}, | ||
@@ -38,4 +39,5 @@ "devDependencies": { | ||
"chai-as-promised": "^5.1.0", | ||
"eslint": "^1.2.1", | ||
"mugshot": "0.0.1", | ||
"eslint": "1.4.3", | ||
"mocha": "^2.3.0", | ||
"mugshot": "0.2.0", | ||
"phantomjs": "^1.9.18", | ||
@@ -42,0 +44,0 @@ "webdriverio": "^3.1.0" |
@@ -1,5 +0,6 @@ | ||
# Chai-Mugshot | ||
# Chai-Mugshot [![Build Status](https://travis-ci.org/uberVU/chai-mugshot.svg?branch=master)](https://travis-ci.org/uberVU/chai-mugshot) | ||
[Chai](http://chaijs.com/) plugin for the [Mugshot](https://github.com/uberVU/mugshot) Visual regression testing lib. | ||
## Install | ||
@@ -11,2 +12,3 @@ | ||
## Usage | ||
@@ -36,3 +38,3 @@ | ||
var browser = new WebdriverIOAdaptor(webdriverioInstance); | ||
var browser = new WebdriverIOAdapter(webdriverioInstance); | ||
var mugshot = new Mugshot(browser); | ||
@@ -71,2 +73,3 @@ | ||
## API | ||
@@ -76,2 +79,3 @@ | ||
### Properties | ||
@@ -78,0 +82,0 @@ |
@@ -25,4 +25,4 @@ var chai = require('chai'); | ||
fs.unlinkSync(paths[i]); | ||
} catch(error) { | ||
if (error.code != 'ENOENT') { | ||
} catch (error) { | ||
if (error.code !== 'ENOENT') { | ||
throw error; | ||
@@ -35,4 +35,4 @@ } | ||
fs.rmdirSync(dir); | ||
} catch(error) { | ||
if (error.code != 'ENOENT') { | ||
} catch (error) { | ||
if (error.code !== 'ENOENT') { | ||
throw error; | ||
@@ -51,6 +51,6 @@ } | ||
}, | ||
noSelector = { | ||
differencesSelector = { | ||
name: name | ||
}, | ||
withSelector = { | ||
noDifferencesSelector = { | ||
name: name, | ||
@@ -80,3 +80,3 @@ selector: '#rectangle' | ||
mugshot.test(withSelector, function(error) { | ||
mugshot.test(noDifferencesSelector, function(error) { | ||
if (error) { | ||
@@ -90,3 +90,3 @@ throw error; | ||
it('should be rejected if mugshot fails', function() { | ||
it('should be rejected with Error if Mugshot fails', function() { | ||
return expect(expect(brokenSelector).to.be.identical).to.be | ||
@@ -96,24 +96,57 @@ .rejectedWith(Error); | ||
it('should not throw if there is no previous baseline', function() { | ||
fs.unlinkSync(path.join(dir, name + ext)); | ||
describe('No baseline', function() { | ||
beforeEach(function() { | ||
cleanUp(); | ||
}); | ||
return expect(expect(withSelector).to.be.identical).to.be.fulfilled; | ||
}); | ||
it('should be fulfilled if expected to be identical', function() { | ||
return expect(expect(noDifferencesSelector).to.be.identical).to.be | ||
.fulfilled; | ||
}); | ||
it('should not throw if there are no differences', function() { | ||
return expect(expect(withSelector).to.be.identical).to.be.fulfilled; | ||
it('should be rejected with AssertionError if expected to not be identical', | ||
function() { | ||
return expect(expect(noDifferencesSelector).to.not.be.identical).to.be | ||
.rejectedWith(AssertionError); | ||
}); | ||
}); | ||
it('should throw error if there are differences', function() { | ||
return expect(expect(withSelector).to.not.be.identical).to.be | ||
.rejectedWith(AssertionError); | ||
describe('No differences', function() { | ||
it('should be fullfilled if expected to be identical', function() { | ||
return expect(expect(noDifferencesSelector).to.be.identical).to.be | ||
.fulfilled; | ||
}); | ||
it('should be rejected with AssertionError if expected to not be identical', | ||
function() { | ||
return expect(expect(noDifferencesSelector).to.not.be.identical).to.be | ||
.rejectedWith(AssertionError); | ||
}); | ||
}); | ||
it('should not throw if there are differences', function() { | ||
return expect(expect(noSelector).to.not.be.identical).to.be.fulfilled; | ||
describe('With differences', function() { | ||
it('should be fulfilled if expected to not be identical', function() { | ||
return expect(expect(differencesSelector).to.not.be.identical).to.be | ||
.fulfilled; | ||
}); | ||
it('should be rejected with AssertionError if expected to be identical', | ||
function() { | ||
return expect(expect(differencesSelector).to.be.identical).to.be | ||
.rejectedWith(AssertionError); | ||
}); | ||
}); | ||
it('should throw if there are no differences', function() { | ||
return expect(expect(noSelector).to.be.identical).to.be | ||
.rejectedWith(AssertionError); | ||
describe('Test Runner Context', function() { | ||
var testRunnerCtx = {}; | ||
before(function() { | ||
chai.use(chaiMugshot(mugshot, testRunnerCtx)); | ||
}); | ||
it('should put the result on the provided object', function() { | ||
return expect(noDifferencesSelector).to.be.identical.then(function() { | ||
expect(testRunnerCtx).to.have.ownProperty('result'); | ||
}); | ||
}); | ||
}); | ||
@@ -120,0 +153,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10838
9
172
82
3
7