Skip to content
This repository

Small note on non-html testing #66

Open
wants to merge 2 commits into from

2 participants

Tim Oxley TJ Holowaychuk
Tim Oxley

Wasn't immediately apparent since all the examples was using the html/dom (admittedly, I did just scan the docs)

TJ Holowaychuk

added 2 more json test, less low level they might be suited better for docs

Tim Oxley

Agreed. Updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 30 additions and 0 deletions. Show diff stats Hide diff stats

  1. 30  Readme.md
30  Readme.md
Source Rendered
@@ -362,6 +362,36 @@ For example:
362 362
       res.should.have.header('Content-Length');
363 363
       res.should.have.header('Content-Type', 'text/html');
364 364
 
  365
+## Testing non-html responses
  366
+
  367
+You can also use tobi to test non-html end-points.
  368
+
  369
+    // JSON
  370
+    browser.get('/json', function(res, obj){
  371
+      obj.should.eql({ user: 'tj' });
  372
+      done();
  373
+    });
  374
+
  375
+    // Test JSON response from a link click
  376
+    browser.get('/users', function(res, $){
  377
+      $('a').click(function(res, obj){
  378
+        obj.should.eql([
  379
+            { name: 'tobi' }
  380
+          , { name: 'loki' }
  381
+          , { name: 'jane' }
  382
+        ]);
  383
+        done();
  384
+      });
  385
+    });
  386
+
  387
+    // XML
  388
+    browser.request('GET', '/xml', {}, function(res){
  389
+      res.should.have.header('Content-Type', 'application/xml');
  390
+      res.should.not.have.property('body');
  391
+      done();
  392
+    });
  393
+
  394
+
365 395
 ## Testing
366 396
 
367 397
 Install the deps:
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.