Created
March 2, 2014 12:11
-
-
Save darthwade/9305669 to your computer and use it in GitHub Desktop.
Protractor toContainClass custom matcher
This file contains 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
beforeEach(function() { | |
this.addMatchers({ | |
toContainClass: function (expected) { | |
var self = this; | |
var deferred = protractor.promise.defer(); | |
self.actual.getAttribute('class').then(function(classes) { | |
var result = classes && classes.search(new RegExp(expected, 'i')) > 0; | |
if (result) { | |
deferred.fulfill(true); | |
} else { | |
deferred.reject(classes + ' did not contain class ' + expected); | |
} | |
}); | |
return deferred.promise; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment