@@ -164,9 +164,13 @@ Asserts that a given subject is `falsy <http://11heavens.com/falsy-and-truthy-in
164
164
165
165
Asserts that a given form field has the provided value::
166
166
167
- casper.start('http://www.google.fr/', function() {
168
- this.fill('form[name="gs"]', { q: 'plop' }, false);
169
- this.test.assertField('q', 'plop');
167
+ casper.test.begin('assertField() tests', 1, function(test) {
168
+ casper.start('http://www.google.fr/', function() {
169
+ this.fill('form[name="gs"]', { q: 'plop' }, false);
170
+ test.assertField('q', 'plop');
171
+ }).run(function() {
172
+ test.done();
173
+ });
170
174
});
171
175
172
176
.. versionadded :: 1.0
@@ -182,8 +186,12 @@ This also works with any input type: ``select``, ``textarea``, etc.
182
186
183
187
Asserts that current `HTTP status code <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html >`_ is the same as the one passed as argument::
184
188
185
- casper.start('http://www.google.fr/', function() {
186
- this.test.assertHttpStatus(200, 'google.fr is up');
189
+ casper.test.begin('casperjs.org is up and running', 1, function(test) {
190
+ casper.start('http://casperjs.org/', function() {
191
+ test.assertHttpStatus(200);
192
+ }).run(function() {
193
+ test.done();
194
+ });
187
195
});
188
196
189
197
``assertMatch() ``
@@ -220,7 +228,7 @@ Asserts that the passed subject resolves to some `falsy value <http://11heavens.
220
228
221
229
Asserts that two values are **not ** strictly equals::
222
230
223
- casper.test.assertNotEquals(true, "Truth is out ");
231
+ casper.test.assertNotEquals(true, "true ");
224
232
225
233
.. seealso :: `assertEquals()`_
226
234
@@ -231,8 +239,13 @@ Asserts that two values are **not** strictly equals::
231
239
232
240
Asserts that the element matching the provided :ref: `selector expression <selectors >` is not visible::
233
241
234
- casper.start('http://www.google.fr/', function() {
235
- this.test.assertNotVisible('h6');
242
+ casper.test.begin('assertNotVisible() tests', 1, function(test) {
243
+ casper.start().then(function() {
244
+ this.setContent('<div class=".foo" style="display:none>boo</div>');
245
+ test.assertNotVisible('.foo');
246
+ }).run(function() {
247
+ test.done();
248
+ });
236
249
});
237
250
238
251
.. seealso :: `assertVisible()`_
@@ -265,8 +278,12 @@ Asserts that the provided function called with the given parameters raises a jav
265
278
266
279
Asserts that given text does not exist in all the elements matching the provided :ref: `selector expression <selectors >`::
267
280
268
- casper.start('http://www.google.fr/', function() {
269
- this.test.assertSelectorDoesntHaveText('title', 'Yahoo!');
281
+ casper.test.begin('assertSelectorDoesntHaveText() tests', 1, function(test) {
282
+ casper.start('http://google.com/', function() {
283
+ test.assertSelectorDoesntHaveText('title', 'Yahoo!');
284
+ }).run(function() {
285
+ test.done();
286
+ });
270
287
});
271
288
272
289
.. seealso :: `assertSelectorHasText()`_
@@ -280,8 +297,12 @@ Asserts that given text does not exist in all the elements matching the provided
280
297
281
298
Asserts that given text exists in elements matching the provided :ref: `selector expression <selectors >`::
282
299
283
- casper.start('http://www.google.fr/', function() {
284
- this.test.assertSelectorHasText('title', 'Google');
300
+ casper.test.begin('assertSelectorHasText() tests', 1, function(test) {
301
+ casper.start('http://google.com/', function() {
302
+ test.assertSelectorDoesntHaveText('title', 'Google');
303
+ }).run(function() {
304
+ test.done();
305
+ });
285
306
});
286
307
287
308
.. seealso :: `assertSelectorDoesntHaveText()`_
@@ -295,12 +316,24 @@ Asserts that given text exists in elements matching the provided :ref:`selector
295
316
296
317
The ``testFx `` function is executed against all loaded assets and the test passes when at least one resource matches::
297
318
298
- casper.start('http://www.google.fr/', function() {
299
- this.test.assertResourceExists(function (resource) {
300
- return resource.url.match('logo3w.png');
301
- }, 'google.fr logo was loaded');
302
- // or shorter
303
- this.test.assertResourceExists('logo3w.png', 'google.fr logo was loaded');
319
+ casper.test.begin('assertResourceExists() tests', 1, function(test) {
320
+ casper.start('http://www.google.fr/', function() {
321
+ test.assertResourceExists(function(resource) {
322
+ return resource.url.match('logo3w.png');
323
+ });
324
+ }).run(function() {
325
+ test.done();
326
+ });
327
+ });
328
+
329
+ Shorter::
330
+
331
+ casper.test.begin('assertResourceExists() tests', 1, function(test) {
332
+ casper.start('http://www.google.fr/', function() {
333
+ test.assertResourceExists('logo3w.png');
334
+ }).run(function() {
335
+ test.done();
336
+ });
304
337
});
305
338
306
339
.. hint ::
@@ -314,8 +347,12 @@ The ``testFx`` function is executed against all loaded assets and the test passe
314
347
315
348
Asserts that body **plain text content ** contains the given string::
316
349
317
- casper.start('http://www.google.fr/', function() {
318
- this.test.assertTextExists('google', 'page body contains "google"');
350
+ casper.test.begin('assertTextExists() tests', 1, function(test) {
351
+ casper.start('http://www.google.fr/', function() {
352
+ test.assertTextExists('google', 'page body contains "google"');
353
+ }).run(function() {
354
+ test.done();
355
+ });
319
356
});
320
357
321
358
.. seealso :: `assertTextDoesntExist()`_
@@ -329,8 +366,12 @@ Asserts that body **plain text content** contains the given string::
329
366
330
367
Asserts that body **plain text content ** doesn't contain the given string::
331
368
332
- casper.start('http://www.google.fr/', function() {
333
- this.test.assertTextDoesntExist('bing', 'page body does not contain "bing"');
369
+ casper.test.begin('assertTextDoesntExist() tests', 1, function(test) {
370
+ casper.start('http://www.google.fr/', function() {
371
+ test.assertTextDoesntExist('bing', 'page body does not contain "bing"');
372
+ }).run(function() {
373
+ test.done();
374
+ });
334
375
});
335
376
336
377
.. seealso :: `assertTextExists()`_
@@ -342,8 +383,12 @@ Asserts that body **plain text content** doesn't contain the given string::
342
383
343
384
Asserts that title of the remote page equals to the expected one::
344
385
345
- casper.start('http://www.google.fr/', function() {
346
- this.test.assertTitle('Google', 'google.fr has the correct title');
386
+ casper.test.begin('assertTitle() tests', 1, function(test) {
387
+ casper.start('http://www.google.fr/', function() {
388
+ test.assertTitle('Google', 'google.fr has the correct title');
389
+ }).run(function() {
390
+ test.done();
391
+ });
347
392
});
348
393
349
394
.. seealso :: `assertTitleMatch()`_
@@ -355,8 +400,12 @@ Asserts that title of the remote page equals to the expected one::
355
400
356
401
Asserts that title of the remote page matches the provided RegExp pattern::
357
402
358
- casper.start('http://www.google.fr/', function() {
359
- this.test.assertTitleMatch(/Google/, 'google.fr has a quite predictable title');
403
+ casper.test.begin('assertTitleMatch() tests', 1, function(test) {
404
+ casper.start('http://www.google.fr/', function() {
405
+ test.assertTitleMatch(/Google/, 'google.fr has a quite predictable title');
406
+ }).run(function() {
407
+ test.done();
408
+ });
360
409
});
361
410
362
411
.. seealso :: `assertTitle()`_
@@ -383,8 +432,13 @@ Asserts that a given subject is `truthy <http://11heavens.com/falsy-and-truthy-i
383
432
384
433
Asserts that the provided input is of the given type::
385
434
386
- casper.test.assertType(42, "number", "Okay, 42 is a number");
387
- casper.test.assertType([1, 2, 3], "array", "Yeah, we can test for arrays too =)");
435
+ casper.test.begin('assertType() tests', 1, function suite(test) {
436
+ test.assertType(42, "number", "Okay, 42 is a number");
437
+ test.assertType([1, 2, 3], "array", "We can test for arrays too!");
438
+ test.done();
439
+ });
440
+
441
+ .. note :: Type names are always expressed in lower case.
388
442
389
443
.. index :: URL
390
444
@@ -395,8 +449,12 @@ Asserts that the provided input is of the given type::
395
449
396
450
Asserts that a the current page url matches the provided RegExp pattern::
397
451
398
- casper.start('http://www.google.fr/', function() {
399
- this.test.assertUrlMatch(/^http:\/\//', 'google.fr is served in http://');
452
+ casper.test.begin('assertUrlMatch() tests', 1, function(test) {
453
+ casper.start('http://www.google.fr/', function() {
454
+ test.assertUrlMatch(/^http:\/\//', 'google.fr is served in http://');
455
+ }).run(function() {
456
+ test.done();
457
+ });
400
458
});
401
459
402
460
.. index :: DOM
@@ -408,8 +466,12 @@ Asserts that a the current page url matches the provided RegExp pattern::
408
466
409
467
Asserts that the element matching the provided :ref: `selector expression <selectors >` is visible::
410
468
411
- casper.start('http://www.google.fr/', function() {
412
- this.test.assertVisible('h1');
469
+ casper.test.begin('assertVisible() tests', 1, function(test) {
470
+ casper.start('http://www.google.fr/', function() {
471
+ test.assertVisible('h1');
472
+ }).run(function() {
473
+ test.done();
474
+ });
413
475
});
414
476
415
477
.. seealso :: `assertNotVisible()`_
0 commit comments