Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ladjs/supertest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.1.6
Choose a base ref
...
head repository: ladjs/supertest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.2.0
Choose a head ref

Commits on May 29, 2020

  1. Add missing require.

    torhovland authored May 29, 2020
    Copy the full SHA
    3537e4e View commit details

Commits on Apr 7, 2021

  1. Copy the full SHA
    fc269b6 View commit details

Commits on Apr 18, 2021

  1. Update README.md

    jtomaszewski authored Apr 18, 2021
    Copy the full SHA
    ad699ed View commit details

Commits on Jan 4, 2022

  1. Copy the full SHA
    d94ffbc View commit details
  2. Merge pull request #747 from jimmywarting/classify

    refactor: Convert test to a class
    niftylettuce authored Jan 4, 2022
    Copy the full SHA
    afecc3f View commit details
  3. Copy the full SHA
    03f0084 View commit details
  4. destruct assert

    jimmywarting committed Jan 4, 2022
    Copy the full SHA
    dc60d5d View commit details
  5. Merge pull request #748 from jimmywarting/var

    refactor: convert var to const / let
    niftylettuce authored Jan 4, 2022
    Copy the full SHA
    1d70492 View commit details
  6. more const

    jimmywarting committed Jan 4, 2022
    Copy the full SHA
    a0a5d57 View commit details
  7. Copy the full SHA
    17cf193 View commit details
  8. user super and arrow fn

    jimmywarting committed Jan 4, 2022
    Copy the full SHA
    d2d9616 View commit details
  9. Copy the full SHA
    1dc25a1 View commit details
  10. Copy the full SHA
    19dcd1e View commit details
  11. use explicit path

    jimmywarting committed Jan 4, 2022
    Copy the full SHA
    cdb0ad9 View commit details
  12. add missing comma

    make lint happy
    jimmywarting committed Jan 4, 2022
    Copy the full SHA
    f17be2a View commit details
  13. var to const

    jimmywarting committed Jan 4, 2022
    Copy the full SHA
    aae4d8e View commit details

Commits on Jan 5, 2022

  1. Merge pull request #749 from jimmywarting/misc

    Misc stuff
    niftylettuce authored Jan 5, 2022
    Copy the full SHA
    a70c1a0 View commit details
  2. Merge pull request #713 from jtomaszewski/patch-1

    docs: Add async/await example to README
    niftylettuce authored Jan 5, 2022
    Copy the full SHA
    70a3d00 View commit details
  3. Merge pull request #653 from torhovland/patch-1

    Add missing require.
    niftylettuce authored Jan 5, 2022
    Copy the full SHA
    88dc262 View commit details

Commits on Jan 10, 2022

  1. chore: bump deps

    niftylettuce committed Jan 10, 2022
    Copy the full SHA
    e741cab View commit details
  2. v6.2.0

    niftylettuce committed Jan 10, 2022
    Copy the full SHA
    0b03531 View commit details
Showing with 3,326 additions and 4,421 deletions.
  1. +20 −1 .gitignore
  2. +16 −0 README.md
  3. +6 −5 index.js
  4. +11 −11 lib/agent.js
  5. +275 −295 lib/test.js
  6. +0 −4,095 package-lock.json
  7. +13 −13 package.json
  8. +1 −1 test/supertest.js
  9. +2,984 −0 yarn.lock
21 changes: 20 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# OS #
###################
.DS_Store
.idea
Thumbs.db
tmp/
temp/


# Node.js #
###################
node_modules


# NYC #
###################
coverage
*.lcov
.nyc_output
.idea


# Files #
###################
*.log
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ test framework at all:

```js
const request = require('supertest');
const assert = require('assert');
const express = require('express');

const app = express();
@@ -125,6 +126,21 @@ describe('GET /users', function() {
});
```

Or async/await syntax:

```js
describe('GET /users', function() {
it('responds with json', async function() {
const response = await request(app)
.get('/users')
.set('Accept', 'application/json')
expect(response.headers["Content-Type"]).toMatch(/json/);
expect(response.status).toEqual(200);
expect(response.body.email).toEqual('foo@bar.com');
});
});
```

Expectations are run in the order of definition. This characteristic can be used
to modify the response body or headers before executing an assertion.

11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@
/**
* Module dependencies.
*/
var methods = require('methods');
var Test = require('./lib/test');
var http = require('http');
const methods = require('methods');
const http = require('http');
const Test = require('./lib/test.js');
const agent = require('./lib/agent.js');

/**
* Test against the given `app`,
@@ -16,7 +17,7 @@ var http = require('http');
* @api public
*/
module.exports = function(app) {
var obj = {};
const obj = {};

if (typeof app === 'function') {
app = http.createServer(app); // eslint-disable-line no-param-reassign
@@ -42,4 +43,4 @@ module.exports.Test = Test;
/**
* Expose the agent function
*/
module.exports.agent = require('./lib/agent');
module.exports.agent = agent;
22 changes: 11 additions & 11 deletions lib/agent.js
Original file line number Diff line number Diff line change
@@ -4,16 +4,10 @@
* Module dependencies.
*/

var Agent = require('superagent').agent;
var methods = require('methods');
var http = require('http');
var Test = require('./test');

/**
* Expose `Agent`.
*/

module.exports = TestAgent;
const { agent: Agent } = require('superagent');
const methods = require('methods');
const http = require('http');
const Test = require('./test.js');

/**
* Initialize a new `TestAgent`.
@@ -50,7 +44,7 @@ TestAgent.prototype.host = function(host) {
// override HTTP verb methods
methods.forEach(function(method) {
TestAgent.prototype[method] = function(url, fn) { // eslint-disable-line no-unused-vars
var req = new Test(this.app, method.toUpperCase(), url, this._host);
const req = new Test(this.app, method.toUpperCase(), url, this._host);
req.ca(this._ca);
req.cert(this._cert);
req.key(this._key);
@@ -69,3 +63,9 @@ methods.forEach(function(method) {
});

TestAgent.prototype.del = TestAgent.prototype.delete;

/**
* Expose `Agent`.
*/

module.exports = TestAgent;
570 changes: 275 additions & 295 deletions lib/test.js

Large diffs are not rendered by default.

4,095 changes: 0 additions & 4,095 deletions package-lock.json

This file was deleted.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "supertest",
"version": "6.1.6",
"version": "6.2.0",
"description": "SuperAgent driven library for testing HTTP servers",
"main": "index.js",
"author": "TJ Holowaychuk",
@@ -33,19 +33,19 @@
},
"dependencies": {
"methods": "^1.1.2",
"superagent": "^6.1.0"
"superagent": "^7.0.1"
},
"devDependencies": {
"body-parser": "1.19.0",
"cookie-parser": "1.4.5",
"coveralls": "3.1.0",
"eslint": "7.17.0",
"eslint-config-airbnb-base": "14.2.1",
"eslint-plugin-import": "2.22.1",
"express": "4.17.1",
"mocha": "8.2.1",
"nock": "13.0.5",
"nyc": "15.1.0",
"should": "13.2.3"
"body-parser": "^1.19.1",
"cookie-parser": "^1.4.6",
"coveralls": "^3.1.1",
"eslint": "^8.6.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.4",
"express": "^4.17.2",
"mocha": "^9.1.3",
"nock": "^13.2.1",
"nyc": "^15.1.0",
"should": "^13.2.3"
}
}
2 changes: 1 addition & 1 deletion test/supertest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const request = require('..');
const https = require('https');
const fs = require('fs');
const path = require('path');
@@ -9,6 +8,7 @@ const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const nock = require('nock');
const request = require('../index.js');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

2,984 changes: 2,984 additions & 0 deletions yarn.lock

Large diffs are not rendered by default.