eslint-plugin-protractor
eslint-plugin-protractor copied to clipboard
Rule Proposal: Recommend to pass promises to expect() directly if possible
There is a common anti-pattern in Protractor when something is explicitly resolved and then asserted instead of passing a promise directly to expect() which is patched to understand promises and resolve them implicitly before making an expectation.
This should issue a warning:
element(by.css("#myid")).getText().then(function (text) {
expect(text).toEqual("My Text");
});
This should be used instead:
expect(element(by.css("#myid")).getText()).toEqual("My Text");
I can imagine that this would not of course catch all the violations of the type, but I think, at the very least, the rule should look that the promise resolution functions argument (text in this case) is not then passed to expect()..