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.4
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.1.5
Choose a head ref
  • 3 commits
  • 4 files changed
  • 2 contributors

Commits on Jul 26, 2021

  1. Mitigate array-of-statuses' impact on JSON bodies

    fixes a regression in #715 / v6.1.4
    swantzter committed Jul 26, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    swantzter Svante Bengtson
    Copy the full SHA
    5a6999a View commit details

Commits on Aug 11, 2021

  1. Merge pull request #728 from swantzter/fix/array-of-statuses-body

    Mitigate array-of-statuses' impact on JSON bodies
    niftylettuce authored Aug 11, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3c46dae View commit details
  2. 6.1.5

    niftylettuce committed Aug 11, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    b735b90 View commit details
Showing with 15 additions and 3 deletions.
  1. +2 −1 lib/test.js
  2. +1 −1 package-lock.json
  3. +1 −1 package.json
  4. +11 −0 test/supertest.js
3 changes: 2 additions & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ function wrapAssertFn(assertFn) {
* .expect(200, body)
* .expect('Some body')
* .expect('Some body', fn)
* .expect(['json array body', { key: 'val' }])
* .expect('Content-Type', 'application/json')
* .expect('Content-Type', 'application/json', fn)
* .expect(fn)
@@ -127,7 +128,7 @@ Test.prototype.expect = function(a, b, c) {
}

// multiple statuses
if (Array.isArray(a)) {
if (Array.isArray(a) && a.every(val => typeof val === 'number')) {
this._asserts.push(wrapAssertFn(this._assertStatusArray.bind(this, a)));
return this;
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "supertest",
"version": "6.1.4",
"version": "6.1.5",
"description": "SuperAgent driven library for testing HTTP servers",
"main": "index.js",
"author": "TJ Holowaychuk",
11 changes: 11 additions & 0 deletions test/supertest.js
Original file line number Diff line number Diff line change
@@ -573,6 +573,17 @@ describe('request(app)', function () {
});
});

it('should support parsed response arrays', function (done) {
const app = express();
app.get('/', function (req, res) {
res.status(200).json(['a', { id: 1 }]);
});

request(app)
.get('/')
.expect(['a', { id: 1 }], done);
});

it('should support regular expressions', function (done) {
const app = express();