Skip to content

Instantly share code, notes, and snippets.

@darthwade
Created March 2, 2014 12:11
Show Gist options
  • Save darthwade/9305669 to your computer and use it in GitHub Desktop.
Save darthwade/9305669 to your computer and use it in GitHub Desktop.
Protractor toContainClass custom matcher
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