I decided to run through the phonecat app tutorial today to sharpen my
knowledge of AngularJS fundamentals. Everything was going along very
smoothly until I came to tutorial step 3 located at:
http://code.angularjs.org/1.2.16/docs/tutorial/step_03
The last section of step 3 says:
-
Add the following end-to-end test into the describe block within test/e2e
/scenarios.js:
1. it('should display the current filter value within an element with id
"status"',
2. function() {
3. var statusElement = element(by.id('status'));
4. expect(statusElement.getText()).toMatch(/Current filter: \s*$/);
5.
6. element(by.model('query')).sendKeys('nexus');
7.
8. expect(statusElement.getText()).toMatch(/Current filter:
nexus\s*$/);
9.
10. //alternative version of the last assertion that tests just the
value of the binding
11. expect(statusElement.element(by.binding('query'))).toBe('nexus');
12. });
Re-run npm run protractor to see the test fail. To make the test pass,
edit the index.html template to add a div or p element with id "status" and
content with the query binding, prefixed by "Current filter:". For
instance:
1. <div id="status">Current filter: {{query}}</div>
However, when I add the <div id="status"> to my index.html file, two of the
assertions fail:
Failures:
1) PhoneCat App Phone list view should display the current filter value
within an element with id "status"
Message:
Expected { click : Function, sendKeys : Function, getTagName :
Function, getCssValue : Function, getAttribute : Function, getText :
Function, getSize : Function, getLocation : Function, isEnabled : Function,
isSelected : Function, submit : Function, clear : Function, isDisplayed :
Function, getOuterHtml : Function, getInnerHtml : Function, findElements :
Function, isElementPresent : Function, evaluate : Function, $$ : Function,
findElement : Function, find : Function, isPresent : Function, element :
Function, $ : Function } to be 'nexus'.
Stacktrace:
Error: Expected { click : Function, sendKeys : Function, getTagName :
Function, getCssValue : Function, getAttribute : Function, getText :
Function, getSize : Function, getLocation : Function, isEnabled : Function,
isSelected : Function, submit : Function, clear : Function, isDisplayed :
Function, getOuterHtml : Function, getInnerHtml : Function, findElements :
Function, isElementPresent : Function, evaluate : Function, $$ : Function,
findElement : Function, find : Function, isPresent : Function, element :
Function, $ : Function } to be 'nexus'.
at null.<anonymous>
(/Library/WebServer/Documents/angular/test/e2e/scenarios.js:38:60)
2) PhoneCat App Phone list view should display the current filter value
within an element with id "status"
Message:
Expected 'Current filter:' to match /Current filter: \s*$/.
Stacktrace:
Error: Failed expectation
at null.<anonymous>
(/Library/WebServer/Documents/angular/test/e2e/scenarios.js:31:41)
My questions:
1) What am I doing wrong that is causing these assertions to fail?
2) Why is expect(statusElement.element(by.binding('query'))).toBe('nexus');
returning
such an odd value?
3) Why isn't expect(statusElement.getText()).toMatch(/Current filter: \s*$/
); matching the value on my "status" div?
Although you can't run protractor in a plunker, I created one anyway to
show you my code: http://plnkr.co/edit/u0QLyvvfCN2SKpE2Ly9C?p=preview
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.