{
  "name": "supertest",
  "version": "0.10.0",
  "description": "Super-agent driven library for testing HTTP servers",
  "main": "index.js",
  "scripts": {
    "test": "make test"
  },
  "dependencies": {
    "superagent": "0.17.0",
    "methods": "0.1.0"
  },
  "devDependencies": {
    "mocha": "*",
    "should": "*",
    "express": "3.1.0"
  },
  "keywords": [
    "superagent",
    "request",
    "tdd",
    "bdd",
    "http",
    "test",
    "testing"
  ],
  "author": {
    "name": "TJ Holowaychuk"
  },
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/visionmedia/supertest.git"
  },
  "readme": "# SuperTest\n\n  HTTP assertions made easy via [super-agent](http://github.com/visionmedia/superagent).\n\n## About\n\n  The motivation with this module is to provide a high-level abstraction for testing\n  HTTP, while still allowing you to drop down to the lower-level API provided by super-agent.\n\n## Example\n\n  You may pass an `http.Server`, or a `Function` to `request()` - if the server is not\n  already listening for connections then it is bound to an ephemeral port for you so\n  there is no need to keep track of ports.\n\n  SuperTest works with any test framework, here is an example without using any\n  test framework at all:\n\n```js\nvar request = require('supertest')\n  , express = require('express');\n\nvar app = express();\n\napp.get('/user', function(req, res){\n  res.send(200, { name: 'tobi' });\n});\n\nrequest(app)\n  .get('/user')\n  .expect('Content-Type', /json/)\n  .expect('Content-Length', '20')\n  .expect(200)\n  .end(function(err, res){\n    if (err) throw err;\n  });\n```\n\n  Here's an example with mocha, note how you can pass `done` straight to any of the `.expect()` calls:\n\n```js\ndescribe('GET /users', function(){\n  it('respond with json', function(done){\n    request(app)\n      .get('/user')\n      .set('Accept', 'application/json')\n      .expect('Content-Type', /json/)\n      .expect(200, done);\n  })\n})\n```\n\n  If you are using the `.end()` method `.expect()` assertions that fail will\n  not throw - they will return the assertion as an error to the `.end()` callback. In\n  order to fail the test case, you will need to rethrow or pass `err` to `done()`, as follows:\n\n```js\ndescribe('GET /users', function(){\n  it('respond with json', function(done){\n    request(app)\n      .get('/user')\n      .set('Accept', 'application/json')\n      .expect(200)\n      .end(function(err, res){\n        if (err) return done(err);\n        done()\n      });\n  })\n})\n```\n\n  Anything you can do with superagent, you can do with supertest - for example multipart file uploads!\n\n```js\nrequest(app)\n.post('/')\n.attach('avatar', 'test/fixtures/homeboy.jpg')\n...\n```\n\n  Passing the app or url each time is not necessary, if you're testing\n  the same host you may simply re-assign the request variable with the\n  initialization app or url, a new `Test` is created per `request.VERB()` call.\n\n```js\nrequest = request('http://localhost:5555');\n\nrequest.get('/').expect(200, function(err){\n  console.log(err);\n});\n\nrequest.get('/').expect('heya', function(err){\n  console.log(err);\n});\n```\n  Here's an example with mocha that shows how to persist a request and its cookies:\n\n```js\nvar request = require('supertest')\n   , should = require('should')\n   , express = require('express');\n\n  \n var app = express(); \n  app.use(express.cookieParser());\n\n\ndescribe('request.agent(app)', function(){\n  var app = express();\n\n  app.use(express.cookieParser());\n\n  app.get('/', function(req, res){\n    res.cookie('cookie', 'hey');\n    res.send();\n  });\n\n  app.get('/return', function(req, res){\n    if (req.cookies.cookie) res.send(req.cookies.cookie);\n    else res.send(':(')\n  });\n\n  var agent = request.agent(app);\n\n  it('should save cookies', function(done){\n    agent\n    .get('/')\n    .expect('set-cookie', 'cookie=hey; Path=/', done);\n  })\n\n  it('should send cookies', function(done){\n    agent\n    .get('/return')\n    .expect('hey', done);\n  })\n})\n```\n  There is another example that is introduced by the file [agency.js](https://github.com/visionmedia/superagent/blob/master/test/node/agency.js)\n\n## API\n\n  You may use any [super-agent](http://github.com/visionmedia/superagent) methods,\n  including `.write()`, `.pipe()` etc and perform assertions in the `.end()` callback\n  for lower-level needs.\n\n### .expect(status[, fn])\n\n  Assert response `status` code.\n\n### .expect(status, body[, fn])\n\n  Assert response `status` code and `body`.\n\n### .expect(body[, fn])\n\n  Assert response `body` text with a string, regular expression, or\n  parsed body object.\n\n### .expect(field, value[, fn])\n\n  Assert header `field` `value` with a string or regular expression.\n\n### .expect(function(res) {})\n\n  Pass a custom assertion function. It'll be given the response object to check. If the response is ok, it should return falsy, most commonly by not returning anything. If the check fails, throw an error or return a truthy value like a string that'll be turned into an error. \n\n  Here the string or error throwing options are both demonstrated:\n\n  ```js\n  request(app)\n    .get('/')\n    .expect(hasPreviousAndNextKeys)\n    .end(done);\n\n  function hasPreviousAndNextKeys(res) {\n    if (!('next' in res.body)) return \"missing next key\";\n    if (!('prev' in res.body)) throw new Error(\"missing prev key\");\n  }\n  ```\n\n### .end(fn)\n\n  Perform the request and invoke `fn(err, res)`.\n\n## Notes\n\n  Inspired by [api-easy](https://github.com/flatiron/api-easy) minus vows coupling.\n\n## License\n\n  MIT\n",
  "readmeFilename": "Readme.md",
  "bugs": {
    "url": "https://github.com/visionmedia/supertest/issues"
  },
  "homepage": "https://github.com/visionmedia/supertest",
  "_id": "supertest@0.10.0",
  "dist": {
    "shasum": "7650f5644e01060ee9d52db4580afa34ec08762c"
  },
  "_from": "supertest@0.10.0",
  "_resolved": "https://registry.npmjs.org/supertest/-/supertest-0.10.0.tgz"
}
