Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: 486 Change method to use deepStrictEqual. #509

Merged
merged 1 commit into from Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/test.js
Expand Up @@ -198,7 +198,7 @@ Test.prototype._assertBody = function(body, res) {
// parsed
if (typeof body === 'object' && !isregexp) {
try {
assert.deepEqual(body, res.body);
assert.deepStrictEqual(body, res.body);
} catch (err) {
a = util.inspect(body);
b = util.inspect(res.body);
Expand Down
31 changes: 31 additions & 0 deletions test/supertest.js
Expand Up @@ -496,6 +496,37 @@ describe('request(app)', function() {
});
});

it('should test response object types', function (done) {
var app = express();
app.get('/', function (req, res) {
res.status(200).json({ stringValue: 'foo', numberValue: 3 });
});

request(app)
.get('/')
.expect({ stringValue: 'foo', numberValue: 3 }, done);
});

it('should deep test response object types', function (done) {
var app = express();
app.get('/', function (req, res) {
res.status(200)
.json({ stringValue: 'foo', numberValue: 3, nestedObject: { innerString: '5' } });
});

request(app)
.get('/')
.expect({ stringValue: 'foo', numberValue: 3, nestedObject: { innerString: 5 } })
.end(function(err, res) {
err.message.should.equal('expected { stringValue: \'foo\',\n numberValue: 3,\n nestedObject: { innerString: 5 } } response body, got { stringValue: \'foo\',\n numberValue: 3,\n nestedObject: { innerString: \'5\' } }'); // eslint-disable-line max-len

request(app)
.get('/')
.expect({ stringValue: 'foo', numberValue: 3, nestedObject: { innerString: '5' } })
.end(done);
});
});

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

Expand Down