Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Small note on non-html testing #66

Open
wants to merge 2 commits into from

2 participants

@timoxley

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

@tj
tj commented

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

@timoxley

Agreed. Updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 18, 2011
  1. @timoxley
  2. @timoxley

    Added improved JSON examples

    timoxley authored
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 0 deletions.
  1. +30 −0 Readme.md
View
30 Readme.md
@@ -362,6 +362,36 @@ For example:
res.should.have.header('Content-Length');
res.should.have.header('Content-Type', 'text/html');
+## Testing non-html responses
+
+You can also use tobi to test non-html end-points.
+
+ // JSON
+ browser.get('/json', function(res, obj){
+ obj.should.eql({ user: 'tj' });
+ done();
+ });
+
+ // Test JSON response from a link click
+ browser.get('/users', function(res, $){
+ $('a').click(function(res, obj){
+ obj.should.eql([
+ { name: 'tobi' }
+ , { name: 'loki' }
+ , { name: 'jane' }
+ ]);
+ done();
+ });
+ });
+
+ // XML
+ browser.request('GET', '/xml', {}, function(res){
+ res.should.have.header('Content-Type', 'application/xml');
+ res.should.not.have.property('body');
+ done();
+ });
+
+
## Testing
Install the deps:
Something went wrong with that request. Please try again.