Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

supertest

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supertest - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

5

History.md
0.4.0 / 2012-10-18
==================
* add url support [vesln]
0.3.1 / 2012-10-01

@@ -3,0 +8,0 @@ ==================

25

lib/test.js

@@ -40,7 +40,5 @@

this._fields = {};
var addr = app.address();
var portno = addr ? addr.port : port++;
if (!addr) app.listen(portno);
var protocol = app instanceof https.Server ? 'https' : 'http';
this.url = protocol + '://127.0.0.1:' + portno + path;
this.url = 'string' == typeof app
? app + path
: this.serverAddress(app, path);
}

@@ -55,2 +53,19 @@

/**
* Returns a URL, extracted from a server.
*
* @param {Server} app
* @param {String} path
* @returns {String} URL address
* @api private
*/
Test.prototype.serverAddress = function(app, path){
var addr = app.address();
var portno = addr ? addr.port : port++;
if (!addr) app.listen(portno);
var protocol = app instanceof https.Server ? 'https' : 'http';
return protocol + '://127.0.0.1:' + portno + path;
};
/**
* Expectations:

@@ -57,0 +72,0 @@ *

2

package.json
{
"name": "supertest",
"version": "0.3.1",
"version": "0.4.0",
"description": "Super-agent driven library for testing HTTP servers",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -53,2 +53,21 @@ # SuperTest

If you are using the `.end()` method `.expect()` assertions that fail will
not throw - they will return the assertion as an error to the `.end()` callback. In
order to fail the test case, you will need to rethrow or pass `err` to `done()`, as follows:
```js
describe('GET /users', function(){
it('respond with json', function(done){
request(app)
.get('/user')
.set('Accept', 'application/json')
.expect(200)
.end(function(err, res){
if (err) return done(err);
done()
});
})
})
```
Anything you can do with superagent, you can do with supertest - for example multipart file uploads!

@@ -59,3 +78,3 @@

.post('/')
.attach('test/fixtures/homeboy.jpg', 'avatar')
.attach('avatar', 'test/fixtures/homeboy.jpg')
...

@@ -62,0 +81,0 @@ ```

@@ -43,2 +43,20 @@

it('should work with remote server', function(done){
var app = express();
app.get('/', function(req, res){
res.send('hey');
});
var server = app.listen(4001, function(){
request('http://localhost:4001')
.get('/')
.end(function(err, res){
res.should.have.status(200);
res.text.should.equal('hey');
done();
});
});
})
it('should work with a https server', function(done){

@@ -45,0 +63,0 @@ var app = express();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc