@@ -97,7 +97,8 @@ the test frame.
97
97
Asserts the value of the given `future` satisfies the `matcher`. All API statements return a
98
98
`future` object, which get a `value` assigned after they are executed. Matchers are defined using
99
99
`angular.scenario.matcher`, and they use the value of futures to run the expectation. For example:
100
- `expect(browser().location().href()).toEqual('http://www.google.com')`
100
+ `expect(browser().location().href()).toEqual('http://www.google.com')`. Available matchers
101
+ are presented further down this document.
101
102
102
103
## expect(future).not().{matcher}
103
104
Asserts the value of the given `future` satisfies the negation of the `matcher`.
@@ -177,6 +178,43 @@ come with almost no-help from the compiler. For this reason we feel very strongl
177
178
written in JavaScript needs to come with a strong set of tests. We have built many features into
178
179
angular which makes testing your angular applications easy. So there is no excuse for not testing.
179
180
181
+ # Matchers
182
+
183
+ Matchers are used in combination with the `expect(...)` function as described above and can
184
+ be negated with `not()`. For instance: `expect(element('h1').text()).not().toEqual('Error')`.
185
+
186
+ Source: {@link https://github.com/angular/angular.js/blob/master/src/ngScenario/matchers.js}
187
+
188
+ <pre>
189
+ // value and Object comparison following the rules of angular.equals().
190
+ expect(value).toEqual(value)
191
+
192
+ // a simpler value comparison using ===
193
+ expect(value).toBe(value)
194
+
195
+ // checks that the value is defined by checking its type.
196
+ expect(value).toBeDefined()
197
+
198
+ // the following two matchers are using JavaScript's standard truthiness rules
199
+ expect(value).toBeTruthy()
200
+ expect(value).toBeFalsy()
201
+
202
+ // verify that the value matches the given regular expression. The regular
203
+ // expression may be passed in form of a string or a regular expression
204
+ // object.
205
+ expect(value).toMatch(expectedRegExp)
206
+
207
+ // a check for null using ===
208
+ expect(value).toBeNull()
209
+
210
+ // Array.indexOf(...) is used internally to check whether the element is
211
+ // contained within the array.
212
+ expect(value).toContain(expected)
213
+
214
+ // number comparison using < and >
215
+ expect(value).toBeLessThan(expected)
216
+ expect(value).toBeGreaterThan(expected)
217
+ </pre>
180
218
181
219
# Example
182
220
See the {@link angular-seed https://github.com/angular/angular-seed} project for an example.
0 commit comments